我创建了一个UploadContactsJobService,在上传完成后扩展了JobService我叫做stopCurrentJob方法
private void stopCurrentJob() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
JOB_INFO = new JobInfo.Builder(JOB_ID,
new ComponentName(RDApp.get(), UploadContactsJobService.class))
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.addTriggerContentUri(
new JobInfo.TriggerContentUri(CONTACTS_URI,
JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS))
.build();
scheduleJob(this);
}
jobFinished(mRunningParams, false);
}
服务被破坏但应用程序进程仍在运行且应用程序仍然在后台运行我在Android Studio上注意到它,我是否应该使用此方法来杀死应用程序进程以防止电池耗尽
android.os.Process.killProcess(android.os.Process.myPid());