Define Android JobService runtime

0

Hello, I need to implement a JobService on Android.

I created the base class for a Job, but I am not able to set a run parameter, minutes, days, hours, etc.

I do not find an example, has anyone implemented and could help me?

public class InformarLocalizacao extends JobService {


@Override
public boolean onStartJob(JobParameters params) {
    return false;
}

@Override
public boolean onStopJob(JobParameters params) {
    return false;
}

}

The <ervice> was added in the manifest, but I need a routine to be called time-in-time ...

    
asked by anonymous 10.10.2018 / 17:16

1 answer

3

To launch the JobService you must use the JobScheduler giving you a JobInfo .

It is the JobInfo that informs the JobScheduler when the JobService should run.

JobInfo defines a set of rules that indicate when and what conditions should be checked for JobService to be released.

O when indicated with setMinimumLatency() and setOverrideDeadline() , and periodicity with setPeriodic() . There are several conditions that can be imposed, including whether or not the device is charging and / or being used. JobInfo is built using a JobInfo.Builder .

Note that the purpose of the JobScheduler is not to perform tasks at given time (a).

    
10.10.2018 / 21:02