问题
I'm trying to run a background task more often than the 15 minutes minimum set by Android.
Battery life isn't a concern and it's for internal use only. I have tried disabling battery optimisation for the app, but that doesn't work either.
Is there anyway to opt out of the battery optimisation?
const component = new android.content.ComponentName(context, org.nativescript.location.BackgroundService26.class);
const builder = new android.app.job.JobInfo.Builder(1, component); builder.setRequiredNetworkType(android.app.job.JobInfo.NETWORK_TYPE_ANY);
builder.setPeriodic(10000)
builder.setRequiresCharging(false);
const jobScheduler = context.getSystemService(android.content.Context.JOB_SCHEDULER_SERVICE);
const service = jobScheduler.schedule(builder.build());
来源:https://stackoverflow.com/questions/58150917/android-background-task-less-than-15-minutes