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 l
You have to add your app in the Android Settings > Protected Apps section on the phone. This lets the user control which apps to allow running in the background.
You could also write a service to listen to the location broadcasts which will run in the background without problem if you get the necessary permissions.
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.