我需要AlarmReceiver
在 10 秒后开始活动(例如)。我需要在不运行应用程序的情况下激活它。但是无论应用程序是否运行,AlarmReceiver
都不会被调用。有什么建议么?
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();