2016-07-25 2 views
0

私は剰余アプリケーションを作成しています。指定された時間にアラームを開始し、ユーザーがそれを停止するまで繰り返します。アラームマネージャからアラームIDを取得する方法

私は、一意の番号を生成し、私はアラームを解除する手順を知っているが、私は放送受信機のクラスでは、このIDを取得する方法を理解することができません、私のAlarmManagerクラスに

 PendingIntent pendingIntent = PendingIntent.getBroadcast(
       this.getApplicationContext(), remainderID.intValue(), intent, 0); 

// remainderID is unqiue value, generated from Database. 

を渡します。

私を親切に案内します。

答えて

0
PendingIntent pendingIntent = PendingIntent.getBroadcast(
      this.getApplicationContext(), remainderID.intValue(), intent, 0); 

上記の目的に必要なその他のデータを追加し、下のAlarmServiceクラスで同じインテントを抽出します。

public class AlarmService extends IntentService { 

    @Override 
    public void onHandleIntent(Intent intent) { 

     if (intent == null) return; 

     try 
     { 
//   send the intent to your AlarmManager class and process it there. 

      YourAlarmManager.processAlarm(intent, this);    
     } catch (Exception e){ 
      e.printStackTrace(); 
     } 
    } 
} 

希望します。 :)

関連する問題