2011-05-13 9 views
0

これは私のコードですが、動作しません。設定でアラームマネージャを使用したサービス

がactivtiy:BroadcastReceiverで

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 
Intent intent = new Intent(this, OnBootReceiver.class); 
pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); 
alarmManager.set(AlarmManager.RTC_WAKEUP, SystemClock.elapsedRealtime()+1000, 
       pendingIntent); 

NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
CharSequence from = "xyz"; 
CharSequence message = "Crazy About Android..."; 
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Settings.class), 0); 
Notification notif = new Notification(R.drawable.icon, "Crazy About Android...", System.currentTimeMillis()); 
notif.setLatestEventInfo(context, from, message, contentIntent); 
mgr.notify(1, notif); 
+0

正確に動作しないものはありますか? –

+0

これで解決策を見つけましたか? – ghostrider

答えて

0

あなたがAlarmManager.RTC_WAKEUPユニットを使用して1秒であなたの意図を開始しようとしている場合、 は、あなたの代わりにSystem.currentTimeMillis()を使用する場合がありますSystemClock.elapsedRealtime()

ここでは相違点について説明します。 http://developer.android.com/reference/android/os/SystemClock.html AlarmManager.RTC_WAKEUPcurrentTimeMillis()と一緒に使用する必要があります。

そうでなければ、フラグを使用することができます。http://developer.android.com/reference/android/app/AlarmManager.htmlAlarmManager.ELAPSED_REALTIME_WAKEUPは、ここで説明されているSystemClock.elapsedRealtime()

国旗で計算時間を提供します。

関連する問題