I have an Android app where I am planning an event (location update) that will be executed in the future using the alarm manager. The scheduled event is executed as expected while the application is running in the foreground or in the background. But as soon as I close the application under the task manager or when the android system kills the application due to a memory problem, when the application is in the background, I can no longer receive the broadcast from the alarm manager.
As suggested by various posts and blogs, I tried to use 1) Intent.Flag_Include_Stopped_Packages 2) android receiver: process = ": remote" in the manifest 3) Android receiver: exported = "true" in the manifest
In the service:
Intent locationIntent = new Intent("com.dummy.intent");
locationIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
locationIntent.putExtra(LocationLibraryConstants.LOCATION_BROADCAST_EXTRA_LOCATIONINFO, locationInfo);
context.sendBroadcast(locationIntent, "android.permission.ACCESS_FINE_LOCATION");
In the manifest:
<receiver android:name=".NearestStationBroadcastReceiver" android:enabled="true"
android:exported="true"
android:process=":remote">
<intent-filter>
<action android:name="com.dummy.intent" />
</intent-filter>
</receiver>
Can anyone help me out?
source
share