我已經開發remindes用戶每10分鐘alertDialog在2小時內只是一個應用程序,如何停止報警android應用
我做了提醒用戶,每次10分鐘的應用程序,但我想2小時後停止它實際上我不能這樣做,
我搜索,但沒有答案,如果我用amManger.cancel();它會2小時之前取消報警:「( 所以,有沒有辦法做到這一點 並請給出一個expamle因爲我是新到Android ...
感謝alooooot ..
?--------------更新後---------------------------
public class MyAlarm extends Activity {
private PendingIntent pendingIntent;
int i = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonStart = (Button) findViewById(R.id.startalarm);
Button buttonCancel = (Button) findViewById(R.id.cancelalarm);
Button bCancel= (Button) findViewById(R.id.button1);
pendingIntent = PendingIntent.getService(MyAlarm.this, 0,
new Intent(MyAlarm.this, MyAlarmService.class), 0);
buttonStart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
long firstTime = SystemClock.elapsedRealtime();
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
AlarmManager am2 = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
firstTime + 10 * 1000, 10 * 1000, pendingIntent);
}
});
bCancel.performClick();
問題: - 當bCancel按鈕自動點擊時,我應該在哪裏停止報警代碼?
-以及如何在兩個小時後進行點擊?
感謝,
謝謝我把他們和我的大部分代碼,但他們的報警並沒有停止,直到用戶點擊StopButton,我需要在2小時後自動報警停止:| | – Samiah 2012-03-15 09:18:27
然後,如果您有任何按鈕,可以使用'performClick()'方法在兩個小時後以編程方式單擊該按鈕。 放置一個2小時後觸發的處理程序,然後放入代碼。讓我知道是否有任何問題。 – Rajkiran 2012-03-15 09:28:56
我沒有任何按鈕來停止該鬧鐘,我不知道如何canu我編程創建一個按鈕!你可以給我任何例子非常感謝 – Samiah 2012-03-15 10:15:56