2011-01-31 6 views
1

次のコードを使用してアラームを作成します。Androidでさらにアラームを設定しますか?

String strDateTime=strDate+" "+strTime;    
      DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm");    
      Date alarmTime = null; 
      try { 
       alarmTime = dfm.parse(strDateTime); 
      } catch (ParseException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

      long setAlarmTime=alarmTime.getTime(); 

      Intent myIntent = new Intent(context, MyAlarmService.class); 
      pendingIntent = PendingIntent.getService(context, 0, myIntent, 0); 

      AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); 

      //set time and get the Intent 
      alarmManager.set(AlarmManager.RTC_WAKEUP, setAlarmTime, pendingIntent); 

私は、複数のアラームを設定する場合、私はアンドロイドで複数のアラーム時間を追加することができますexecuted.How最後の1になりますか?

答えて

1

は、すべてのAlarmManager.setコール

AlaramManagerは、以前に同じPendingIntentに設定し、アラームをリセットします(とあなたのPendingIntentsが常に上(setDatコール経由)あなたのIntent(コードでmyIntent)いくつかのランダムなデータのすべてを与えるようにしてください同じ)

関連する問題