Android Broadcast receiver not executed on application close
android, broadcastreceiver, intentfilter
Solution
But once I force close the application under task manager or when android system kills the application due to memory issue when the app is at background, I am no longer able to receive the broadcast from the alarm manager.
These have nothing to do with each other, so if you have been simulating "when android system kills the application due to memory issue" by using Force Stop, that is your problem. An app that has been force-stopped through Settings has its alarms removed, among other things. A better way to simulate your process being terminated is to terminate it from DDMS.
1) Intent.Flag_Include_Stopped_Packages 2) receiver android:process=":remote" in manifest 3) receiver android:exported="true" in manifest
None of those are related to your problem, and `android:exported="true"` (and your use of an `<intent-filter>`) raises security issues, as now anyone can cause your `BroadcastReceiver` to be run at any time, for any reason.
Here is a sample application that successfully processes alarm events, even after the process has been terminated by DDMS.
Problem
I have an android application, where I schedule to an event (location update) to be executed in the future using Alarm manager. The scheduled event executes as expected as long as the application runs in the foreground or in the background. But once I force close the application under task manager or when android system kills the application due to memory issue when the app is at background, I am no longer able to receive the broadcast from the alarm manager. As suggested by various posts and blogs i tried using 1) Intent.Flag_Include_Stopped_Packages 2) receiver android:process=":remote" in manifest 3) receiver android:exported="true" in manifest In 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 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 someone please help me out?