FileDocCategorySizeDatePackage
AlarmService.javaAPI DocAndroid 1.5 API3263Wed May 06 22:41:08 BST 2009com.example.android.apis.app

AlarmService

public class AlarmService extends android.app.Activity
This demonstrates how you can schedule an alarm that causes a service to be started. This is useful when you want to schedule alarms that initiate long-running operations, such as retrieving recent e-mails.

Fields Summary
private android.app.PendingIntent
mAlarmSender
private android.view.View.OnClickListener
mStartAlarmListener
private android.view.View.OnClickListener
mStopAlarmListener
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);

        // Create an IntentSender that will launch our service, to be scheduled
        // with the alarm manager.
        mAlarmSender = PendingIntent.getService(AlarmService.this,
                0, new Intent(AlarmService.this, AlarmService_Service.class), 0);
        
        setContentView(R.layout.alarm_service);

        // Watch for button clicks.
        Button button = (Button)findViewById(R.id.start_alarm);
        button.setOnClickListener(mStartAlarmListener);
        button = (Button)findViewById(R.id.stop_alarm);
        button.setOnClickListener(mStopAlarmListener);