BroadcastReceiver not working when I kill my application

后端 未结 2 1665
我在风中等你
我在风中等你 2020-12-06 06:32

I have noticed than whenever I manually kill my application by longpressing the back button of my cellphone my broadcast receiver stops working. The receiver is in charge of

相关标签:
2条回答
  • 2020-12-06 07:18

    I know that some devices (like my ASUS) are deleting static receivers when you stop an application, yours is probably one of those. The only thing you can do is trying with emulator or other device.

    0 讨论(0)
  • 2020-12-06 07:31

    There are ~7 billion people on the planet. Only you know what you mean by "kill".

    The symptoms that you are describing, though, are consistent with a "force stop". A user normally force-stops an application by going to Settings, finding your app in the list of installed apps, and tapping on the "Force Stop" button for your app. There are some devices and firmware builds that make "Force Stop" more readily accessible than this -- such devices and firmware builds were written by drooling idiots IMHO.

    If your app is force-stopped, your code will never run again, until something uses an explicit Intent to start one of your components. Usually, the user does this by tapping on your app's icon in the home screen's launcher. Until the user does this, your BroadcastReceiver will not work, and there is nothing you can do about it.

    Rather than using some on-device feature to "kill" your app, try terminating its process via DDMS. If your app continues to work in that case, then however you elected to "kill" your app before is doing a "force-stop". Merely having your process be terminated, such as due to low memory conditions, should not prevent you from receiving future broadcasts.

    0 讨论(0)
提交回复
热议问题