0
如果我試圖做定時notifacation,它只是不工作,幫助?安卓鬧鐘應用程序 - 接收器未啓動
設置報警:
Intent intent = new Intent(context, MyAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent,0);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent); //calendar is declared and taking it's values from a time picker
接收機:
public class MyAlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Log.wtf("ddd", "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
Intent service1 = new Intent(context, MyAlarmService.class);
context.startService(service1);
}
}
清單:
<receiver android:name="MyAlarmReceiver" >
<intent-filter>
<action android:name="REFRESH_THIS" />
</intent-filter>
</receiver>
提供你得到通過logcat的什麼錯誤! –
AlarmManager.RTC,嘗試將其更改爲AlarmManager.RTC_WAKEUP –
您是否已經仔細檢查過您是否獲得了「日曆」的預期值? – codeMagic