Android AlarmManager在模拟器中启动,但不在物理设备上启动
我有一个调用AlarmManager的应用程序Android AlarmManager在模拟器中启动,但不在物理设备上启动,android,broadcastreceiver,alarmmanager,Android,Broadcastreceiver,Alarmmanager,我有一个调用AlarmManager的应用程序 Intent intent; intent = new Intent(context, MyEventReceiver.class); PendingIntent appIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); AlarmManager alarmManager = (AlarmManager) getSystemS
Intent intent;
intent = new Intent(context, MyEventReceiver.class);
PendingIntent appIntent = PendingIntent.getBroadcast(context, 0,
intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
appIntent);
在修指甲的时候,我有义务进入
<receiver android:name=".MyEventReceiver"
android:process=":remote" />
当警报被激活时,即使我的应用程序没有运行,也应该启动MyEventReceiver并执行某些操作。在模拟器中是这样,但在实际设备上不是这样
例如,我将在emulator上启动MyApplication,在DDMS中我可以看到MyApplication的运行过程。我在MyApplication中添加了一个警报,然后在DDMS中终止MyApplication的进程。当警报触发时,MyEventReceiver执行其工作,在DDMS中,我看到两个进程:MyApplication和MyApplication:remote
在实际设备上,如果我启动我的应用程序,添加一个警报,然后在警报没有执行时使用任务杀手终止进程。如果我将设备连接到调试器,并使用DDMS而不是设备上的task killer停止进程,则警报将触发并按预期工作
有人能帮我理解为什么会这样吗?我的印象是,一旦警报被安排,它将持续,除非设备重新启动。在执行警报时,设备处于唤醒状态
在修指甲的时候,我有
强制入境
<receiver android:name=".MyEventReceiver"
android:process=":remote" />
android:process=“:remote”
是反强制的。请把它拿走。快点
在实际设备上,如果我启动
MyApplication,添加一个警报,然后
使用任务杀手杀死进程
任务杀手也会删除应用程序的警报,不过这个问题在安卓2.2上得到了解决。我在这里看到了这个
:remote
。用于什么以及何时需要?@Pentium10:它强制组件(在本例中为BroadcastReceiver
)在独立于其他组件的进程中运行。考虑到大多数Android设备在RAM上有多紧,我不知道SDK应用程序为什么要使用它。几乎每个教程都使用process=“:remote”,这也是我的问题。谢谢你的澄清!