Search code examples
javaandroidbroadcastreceiver

Android broadcast receiver when the app is in background


I'm facing a problem with the android broadcast receiver. I have a login page and after a successful login the app goes to another activity. And it contains a broadcast receiver. I am sending a broadcast once a separate service completes its action. The app works fine in a happy day scenario.

My problem here is, after i entered the username / password and hit the login button i send the app to the background. But when the app is in background that broadcast receiver wont receive the broadcast which i'm sending.

Anyone have a clue regarding this issue ?

Any help would be greatly appreciated. Thanks in advance.


Solution

  • Are you unregistered the broadcast receiver in any of the activities onPause/OnStop/OnDestroy method? if yes then you will not receive the broadcast. make sure you have register the Broadcast receiver in the AndroidManifest. and not unregistered. if you wanted to receive intent in the background then you should not unregistered it.