I have used broadcast receiver to check network connection, but with android 7.0 it's not allowed any more. So, I want to handle this problem with Job Scheduling, but I do not know how to do it. Is there any good resource about Job Scheduling or piece of code that check network status with Job Scheduling.
Asked
Active
Viewed 569 times
0
-
checkout this link https://github.com/firebase/firebase-jobdispatcher-android might be helpful fro you – Rahul Feb 19 '18 at 07:00
-
check this answer: https://stackoverflow.com/a/39880860/5846135 – Zeero0 Feb 19 '18 at 07:02
-
thank u for responses. – Tugberk Feb 19 '18 at 07:16
1 Answers
1
Frameworks, like Android JobScheduler or Firebase Jobdispatcher provide a feature that allow you to define constraints when a job should be executed. One constraint might be that network has to be available.
There are some implementations for Job scheduling on Android, like Android Jobscheduler or Firebase Jobdispatcher. This gives you an overview
If you use Firebase Jobdispatcher, you can define that you Job should only be executed if network is available, like this:
Job myJob = dispatcher.newJobBuilder()
// the JobService that will be called
.setService(MyJobService.class)
// uniquely identifies the job
.setTag("my-unique-tag")
// constraints that need to be satisfied for the job to run
.setConstraints(
// only run if any network is available
Constraint.ON_ANY_NETWORK
)
.build();
dispatcher.mustSchedule(myJob);
Source: Firebase Jobdispatcher

Christopher
- 9,682
- 7
- 47
- 76
-
1thank you for your response, I'll look them, but I'm looking for more completed samples. – Tugberk Feb 19 '18 at 07:17