Reputation: 31
https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html
ConnectivityManager.CONNECTIVITY_ACTION will not working statically in Android 7.0 as per Android Developer but why it is not working in older versions of android
Upvotes: 0
Views: 709
Reputation: 38595
You do not need to monitor network connectivity at all times for this use case. When the user is using your app, then you can check network as per the link you provided. If you are not connected, you can use the JobScheduler
to schedule a job and use jobInfoBuilder.setRequiredNetworkType(NETWORK_TYPE_ANY)
, and the system will run your job when there is network connectivity even if your app has since gone to the background. The job should simply start up a Service that uploads whatever changes are pending.
Alternatively, if it fits your use case, you can write a SyncAdapter
and simply request a sync, and the system's SyncManager
will run your SyncAdapter
when appropriate.
Upvotes: 1