开发者

How to receive broadcast event even when my App is in background in android

开发者 https://www.devze.com 2023-03-08 05:30 出处:网络
I 开发者_C百科 have aappwhich isa singleactivity app ,itlistensto many broadcastevent, myquestion isthathowcan Iensure that I receiveall thefiredintentwhich ihaveaddedfor my appevenwhenmyappis notinfo

I 开发者_C百科 have a app which is a single activity app , it listens to many broadcast event , my question is that how can I ensure that I receive all the fired intent which i have added for my app even when my app is not in foreground and running in background ??

is there a certain method where I should add my intent filter and do the registerReciever ? I'm sure it won't work if I keep it in "Oncreate"

any ideas or help ??


It sounds like you want to be using a BroadcastReceiver to pick up the events when you are in the 'background'. This will pick up events which are actually broadcast without having to launch a UI.

You can set up the BroadcastReceiver and its intent filters in the manifest for your application, this way you dont have to rely on any java code being run to register the receivers.

0

精彩评论

暂无评论...
验证码 换一张
取 消