2017-03-20 10 views
1

誰もスヌーズ機能の実行方法やどこに間違っているのか知っていますか?「スヌーズ」アラームに問題がある

デフォルトのスヌーズ時間は5分です。
アプリケーションを再起動するまで正常に機能していましたが、再度動作しません。 キャッシュをクリアしてデータを再度取り出すと

public void onClick(View view) { 

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); 
    int iSnoozeLeft = settings.getInt(PuzzleAlarm.SNOOZE_LEFT, 1); 
    if (iSnoozeLeft != 0) { 
     Intent activate = new Intent(AlarmNotification.this, AlarmReceiver.class); 
     PendingIntent alarmIntent = PendingIntent.getBroadcast(AlarmNotification.this, 0, activate, 0); 
     AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 

     int iMinutes = Preferences.getSnooze(settings, AlarmNotification.this); 
     Calendar calendar = Calendar.getInstance(); 
     calendar.roll(Calendar.MINUTE, iMinutes); 
     alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmIntent); 

     SharedPreferences.Editor editor = settings.edit(); 
     editor.putInt(PuzzleAlarm.SNOOZE_LEFT, iSnoozeLeft - 1); // disabling 
     // Commit the edits! 
     editor.commit(); 
    }` 
+0

再構成して読みやすくしてください。英語を改善しました。 – theblitz

答えて

0

PendingIntent.getBroadcast(AlarmNotification.this、、活性化、0);

他のアラームIDに「0」を使用していないことを確認してください。他のケースでは、 "スヌーズ"コードがその前のアラームを上書きします。

+0

あなたは正しいですが、私はアプリケーションを再起動すると、なぜ私はそれを編集し、アラーム時間を設定した後に作成された同じアラームが発生した起こった..それは最初に作成された同じID .. –

+0

別のものは、アラームまたは3番目のアラームは、アプリケーションが初めて起動したときにうまく動作しますが、私はアプリを再起動しても何も得られません... –

関連する問題