MyApp\'s Receiver is just working fine if it in background which is:
public class MySmsReceiver extends WakefulBroadcastReceiver {
@Override
pub
On some Huawei devices (and some LG and Xiaomi devices) you need to add your app to the list of apps that are allowed to run in the background. If you don't, once your app is stopped (by swiping from the recent tasks list, or by Android killing the app for resource reasons), it will NOT be automatically restarted.
On Huawei devices, the setting is called "protected apps". You cannot programmatically add your app to the list of "protected apps". You need to tell the user that he has to do it after you've installed your app. Well-known apps (like Whatsapp, Facebook, Google Mail) are automatically added by the manufacturer.
This behaviour may be different on different devices and it may be different on different versions of Android and it may be different if the device is "branded" for a specific mobile operator, as the mobile operators can also tinker with the settings themselves.
See "Protected Apps" setting on Huawei phones, and how to handle it for some more details.
EDIT: Added this:
Also, Android broke the "swipe from recents" behaviour in Android 4.4 (Kitkat) so that it causes problems for apps that have been swiped. Sticky services don't get retarted and broadcast Intent
s are not delivered. There is some information here about workarounds to deal with that: In android 4.4, swiping app out of recent tasks permanently kills application with its service . Any idea why?
Also, have you installed your app from the Google Play store? It is possible that the behaviour is different for apps that have been installed from the Play store versus apps that are locally installed (from downloads or via adb
or whatever).