
1.服务
public class NotificationService extends JobService { private voID PrintLog() { Log.d("DGVCL","PrintLog()"); } @OverrIDe public boolean onStartJob(JobParameters jobParameters) { Log.d("DGVCL","onStartJob()"); PrintLog(); jobFinished(jobParameters,false); return true; } @OverrIDe public boolean onStopJob(JobParameters jobParameters) { Log.d("DGVCL","onStopJob()"); return true; }} 2.主要活动
JobScheduler jobScheduler = (JobScheduler)getApplicationContext().getSystemService(JOB_SCHEDulER_SERVICE); Componentname componentname = new Componentname(this,NotificationService.class); JobInfo jobInfo = new JobInfo.Builder(1,componentname) .setPeriodic(Global.NOTIFICATION_TIME_PERIOD) .setBackoffCriteria(Global.NOTIFICATION_TIME_PERIOD,JobInfo.BACKOFF_POliCY_liNEAR) .setPersisted(true).build(); jobScheduler.schedule(jobInfo);
3.清单
<service androID:name="com.hopesndreams.hiren.hd.service.NotificationService" androID:permission="androID.permission.BIND_JOB_SERVICE" > </service>解决方法 @hiren patel ..看看这个例子..它的工作正常.
Job Scheduler in Background
我认为您需要在杀死或销毁之前安排调度程序.
>作业调度程序有限制
>它不会在线下工作.
>其时间为15分钟,15分钟后自动停止服务,我们必须重新开始或重新安排工作.
谢谢..
总结以上是内存溢出为你收集整理的android – Job Scheduler服务在应用程序被杀死时无效全部内容,希望文章能够帮你解决android – Job Scheduler服务在应用程序被杀死时无效所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)