Check if there is any pending PeriodicTask

0

I'm using GcmNetworkManager (without firebase) to program a PeriodicTask that is repeated every certain period of time (the task connects to a web with an AsyncTask, checks some data and launches or not a notification depending on what you get) and that keep between restarts.

With short periodicities I check that it is maintained, but I do not know if with intervals of hours the system can get rid of the tasks.

The code that does this is simple:

GcmNetworkManager netMan = GcmNetworkManager.getInstance(this);

PeriodicTask tarea = new PeriodicTask.Builder()
                    .setService(CompruebaValoresService.class)
                    .setPeriod(INTERVALO_MIN*60)
                    .setFlex(INTERVALO_MIN*6)
                    .setRequiresCharging(false)
                    .setPersisted(true)
                    .setUpdateCurrent(true)
                    .setTag(SERVICE_TAG)
                    .build();

netMan.schedule(tarea);

On the one hand, the task is not very critical, so I set a high periodicity (4 or 8 hours) and 10% flexibility. On the other hand, the user may have the feeling that this is not working and needs "a test" (now I show him the last time the check was done)

Is there a way to check if there are any pending tasks? In the GcmNetworkManager documentation there are only a few methods and constants that do not tell me much (or I do not see it)

Thanks in advance!

    
asked by Adolfo I. C. 24.03.2018 в 12:51
source

0 answers