pwittchen / ReactiveNetwork

Android library listening network connection state and Internet connectivity with RxJava Observables
http://pwittchen.github.io/ReactiveNetwork/docs/RxJava2.x/
Apache License 2.0
2.53k stars 276 forks source link

How to check Internet Connection in Background continuously even if App is Running or Not/Closed.. #470

Open patelakshay13890 opened 1 year ago

patelakshay13890 commented 1 year ago

How Check Internet Connection in Broadcast Receiver or Service Like as we do in Activity ? But I need in Service or Broadcast Receiver.. Means I need to check Internet Connation in Background continuously even if App is Running or Not/Closed.. As on Internet Connectivity change I want to Sync My Data to Server so please help me out..!! Thanks..

pwittchen commented 1 year ago

Hi @patelakshay13890,

This library is designed to be used while app is running and active. If the Activity is inactive (in background) then library should not detect changes and it should start detecting connectivity changes again when app is active (in foreground) again.

If you want to use library when app is inactive (in the background), then you should create an Android Service and then use it inside Service. Of course, you need to dispose appropriate subscription/disposable, when Service is being closed or destroyed.