Android N: problem with missing CONNECTIVITY_CHANGE

My AppWidgetProvider (which, of course, BroadcastReceiver ) is registered to receive CONNECTIVITY_CHANGE , so I can update widgets immediately after restoring the network (although only if necessary, that is, if the previous update was skipped due to lack of connection).

But as stated here , this will no longer be possible in Android N. It is supposed to use JobScheduler , which allows you to run the task only when connected to the network using the .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) method.

However, I do not see how this can be used to replicate my desired behavior. It seems to me that the .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) method will cause Job to not run at all if there is no network at the time the job is assigned and it will not . > make Job wait patiently until the network appears, and then run (what I need).

So, how do I save the behavior I need with Android N?

+6
source share
2 answers

I use Task Schedulers, and this does not depend on whether the network is available or not when scheduling a task. It provides certain conditions and when these conditions are satisfied, the task is scheduled. You can set repetitive work, as well as specify the minimum time interval between tasks. For example, whenever I connect my phone to charging, the PlayStore starts updating applications, because the task has a charging limit.

If you are planning a task and the conditions are not met, he will plan when the network will be available. Try turning off the network and opening your profile on Facebook. He will ask you to upload a profile on the network. Now connect to the network and you will receive a notification after downloading the profile.

0
source

try adding Google ping to change the network, which will help you change the network and for all the reasons I have the same problem when I developed with socket services. Perhaps this will also help you.

0
source

All Articles