Android Background Task - Less Than 15 Minutes

女生的网名这么多〃 提交于 2021-01-29 04:08:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!