[Alarm Service.java]

 private OnClickListener mStartAlarmListener = new OnClickListener() {
        public void onClick(View v) {

            long firstTime = SystemClock.elapsedRealtime();

            AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                            firstTime, 30*1000, mAlarmSender);

            Toast.makeText(AlarmService.this, R.string.repeating_scheduled,
                    Toast.LENGTH_LONG).show();
        }
 

  };

    private OnClickListener mStopAlarmListener = new OnClickListener() {
        public void onClick(View v) {
 
            AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
            am.cancel(mAlarmSender);

               Toast.makeText(AlarmService.this, R.string.repeating_unscheduled,
                    Toast.LENGTH_LONG).show();

        }
    };

}



[Manifest.xml]

<service android:name=".app.AlarmService_Service" android:process=":remote" />

        <activity android:name=".app.AlarmService" android:label="@string/activity_alarm_service">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>


 

'old > API_Demo' 카테고리의 다른 글

APP_Intents  (0) 2010.03.23
APP_Dialog_AlertDialogSamples  (0) 2010.03.22
APP_Alarm_AlarmController  (0) 2010.03.16
APP_Activity_Wallpaper  (0) 2010.03.16
APP_Activity_TranslucentBlurActivity  (0) 2010.03.16
Posted by jazzlife
,