android - Unregistering Broadcast Receiver when application goes to background -


i need check net connectivity in application. nothing should work if there no internet connectivity. have implemented using broadcastreceivers, want receivers unregistered (i.e. not getting called) when application in background. receiver should work when user using app.

initially, had broadcast receiver registered in manifest, noticed got fired when app in background. so, chucked idea.

then, registered receiver in onresume(), , unregistered in onpause(). but, problem if go activity activity b of application, receiver unregistered on onpause() of , again registered in onresume() of b. makes activity transition heavy. though, in such case unregister , register process shouldn't happen.

i want receiver unregistered when user stops using app, not during activity transitions, should not keep running when app in background. thought of using services, want detect change in net connectivity, done best receivers.

so, there way detect when app goes in background can unregister receiver? if not, best way achieve requirement?

i have code registering, unregistering receivers , detecting connectivity changes already.

check out tutorial , register/unregister receiver @ correct spots.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -