简体   繁体   中英

Android broadcast receiver running always

How do I make a broadcast receiver which runs always, from the very start of the device? Is this possible without starting the application where it is declared?

If not I guess I would have to start my application when the device starts. But this probably adds to much overhead and it's unwanted.

I want this always runnning broadcast receiver in order to listen always for c2dm notifications. These should notify the user that there are new messages in the application.

如果您使用“意图过滤器”将“ BroadcastReceiver”添加到“清单”中以侦听特定意图,则“接收器”在安装时将处于活动状态。

what do you mean "run always" ?

if you need something to be alive for a long time , and from the OS bootup , you need to :

  1. let the app to be installed only on the internal storage (otherwise it won't work).

  2. set the broadcast receiver to listen to the boot intent .

  3. upon receiving the boot intent, start a service and there listen to the intent you wish to listen to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM