[英]Broadcast receiver not exceuted on application force close
我有一个为果冻豆开发的应用程序,在该应用程序中,我安排了一个事件,以后将使用Alarm Manager来执行该事件。 只要应用程序在前台或后台运行,计划的事件就会按预期执行。 但是,一旦我在taskmanager下强制关闭应用程序,我将不再能够接收警报管理器的广播。
正如各种帖子和博客所建议的那样,我尝试使用Intent.Flag_Include_Stopped_Packages。 但这没有用。 在意图中包含此标志仅对sendBroadcast(intent)有效。 但是,对于使用挂起意图的警报管理器而言,它将不起作用。
我的计划警报的代码
Intent intent = new Intent("com.dummy.intent");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(),dummyId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarm = (AlarmManager)getSystemService(ALARM_SERVICE);
alarm.set(AlarmManager.RTC_WAKEUP, scheduledAlarm.getTimeInMillis(), pi);
我的主要节日
<receiver android:name="com.example.androidScheduling.alarmReceiver"
android:enabled="true"
android:exported="true"
android:process=":remote">
<intent-filter>
<action android:name="com.dummy.intent"></action>
</intent-filter>
</receiver>
有人可以帮我吗? 我什至尝试在清单中包括android:process = ":remote"
作为接收者。 但是,即使那样也没有帮助。
我认为您没有在清单和程序中正确拼写意图的动作名称。
In pro-grammatically
Intent intent = new Intent("com.dummy.intent");
Manifest file
-
<intent-filter>
<action android:name="com.custom.intent"></action>
</intent-filter>
The action name to intent and declared in manifest must require same
。
希望这对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.