Java – Android broadcast receiver when the application is in the background

Android broadcast receiver when the application is in the background… here is a solution to the problem.

Android broadcast receiver when the application is in the background

I’m having a problem with the android broadcast receiver. I have a login page and after a successful login, the application goes to another activity. It contains a broadcast receiver. Once the individual service has finished its operation, I will send the broadcast. The app works well in the happy day scenario.

My problem is that after I enter my username/password and hit the login button, I send the app to the background. But when the app is in the background, the broadcast receiver will not receive the broadcast I sent.

Does anyone know about this issue?

Any help would be appreciated.
Thanks in advance.

Solution

Did you unregister the broadcast receiver in the onPause/OnStop/OnDestroy method of any activity? If yes, then you will not receive the broadcast. Make sure that you have registered the broadcast receiver in AndroidManifest. Instead of unregistered. If you want to receive intents in the background, you should not unregister.

Related Problems and Solutions