Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BroadCast Receiver stopped working #459

Open
Ankit0080 opened this issue Apr 11, 2021 · 5 comments
Open

BroadCast Receiver stopped working #459

Ankit0080 opened this issue Apr 11, 2021 · 5 comments

Comments

@Ankit0080
Copy link

After using this library my broadcast receiver which was working fine before inside the same activity stopped working

@pwittchen
Copy link
Owner

pwittchen commented Apr 11, 2021

Hi @Ankit0080,

Under the hood library uses broadcast receivers for detecting application idle state or network change depending on the Android version installed on the device. If your activity is using one of these receivers, they may interfere with this library. You should decide if you want to use this library or custom receivers to monitor device state. Another solution, may be creating custom implementation of the network observing strategies for the library and override default behavior. It's possible, but you will loose most of the functionalities of the library. It all depends on your specific case and the goal you want to achieve.

Regards,
Piotr

@Ankit0080
Copy link
Author

Ankit0080 commented Apr 11, 2021

@pwittchen I am using broadcast receivers for some other task not for Connectivity and that broadcast event stopped firing after using library SO is there any way around.?

@pwittchen
Copy link
Owner

pwittchen commented Apr 11, 2021

It's strange. I have never heard of such issues before. My only guess is the fact that broadcast receivers inside the library cannot work with your custom broadcast receivers, but I'm not sure about that.

Possible workarounds (I'm not sure if they will work, it's just my guess):

  • avoid using observing network connectivity and use observing internet connectivity instead
  • implement custom network observing strategy, but it's hard for me to say how to do that for your use case
  • force usage of LollipopNetworkObservingStrategy in your app and set min sdk version for Android Lollipop (this strategy does not use any broadcast receivers - broadcast receivers are used by MarshmallowNetworkObservingStrategy and PreLollipopNetworkObservingStrategy) - you can use method observeNetworkConnectivity(context, strategy) to do that - this will limit users of your app for only those with newer Android version, but it may help to fix this issue

@Ankit0080
Copy link
Author

@pwittchen ok thanks for your support i will follow these steps you mentioned to sort out the issue

@Ankit0080
Copy link
Author

@pwittchen I tried your suggestion they aren't working and then i removed the code from same activity where i am using broadcast receiver and guess what broadcast receiver started working so i guess there is conflict between this library and Custom Broadcast receiver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants