我需要在10秒鐘後(例如)啓動活動AlarmReceiver
。我需要它在沒有運行應用程序的情況下被激活。但是,無論應用程序是否運行,AlarmReceiver
都不會被調用。有什麼建議麼?AlarmManager不工作
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 111, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
//alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
//+ (10 * 1000), pendingIntent);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
你試過@Pratik D的答案? –