How to detect network outages in Firebase Manager?

In firebase Job dispatcher can be detected when we connect to the network, but how to determine when we disconnect from the 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 be detected when connecting to a non-routed network, I want to start the service when it is disconnected from all networks.

+4
source share
1 answer

With the firebase manager you cannot check the disconnect (as far as I know), but you can use broadcast receivers to detect connection changes and call the work service inside them

refers to this link to use broadcast receivers

Broadcast receiver to test Internet connection in Android application

android

+1

Source: https://habr.com/ru/post/1688485/


All Articles