In firebase Job dispatcher its possible to detect when we connect to a network, but how to detect when we disconnect from a network?
Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag("my-unique-tag")
.setConstraints(
// only run on an unmetered network
Constraint.ON_UNMETERED_NETWORK,
// only run when the device is charging
Constraint.DEVICE_CHARGING
)
.build();
dispatcher.mustSchedule(myJob);
This will detect when connected to Unmetrered Network , i want to start a service whenever it is disconnected from all networks