android-jobscheduler

SyncAdapter vs JobScheduler

大城市里の小女人 提交于 2019-12-22 03:25:48
问题 Excluding the fact that JobScheduler only supports API > 21 - are JobSchedulers designed to fully replace SyncAdapters ? Or does SyncAdapter contain any functionality lacking by JobScheduler ? My use case is syncing an RSS feed every couple of hours. This is doable with a JobScheduler - right? 回答1: I would say JobScheduler is not a direct substitution for SyncAdapter , which has a much more specialized purpose (transferring data between the device and a server). JobScheduler , on the other

How do I test my JobService with an Instrumentation test?

人走茶凉 提交于 2019-12-20 12:38:49
问题 I have a JobService that is properly implemented and works fine in simple cases but I want to ensure the service is properly tested in all conditions. I'd like to use an Instrumentation test case so that I can test the full flow from the scheduling of the job with getSystemService(JobScheduler.class).schedule(job) to the invocation of onCreate in my JobService and my onStartJob / onStopJob calls. My JobService launches AsyncTask s sometimes (thereby returning true in onStartJob ) and other

JobScheduler not repeating job

为君一笑 提交于 2019-12-19 03:39:23
问题 I'm using a JobScheduler.setPeriodic() to repeat my JobIntentService. It works the first time but never repeats. Running on Android 7.0 ConcurrentCheck.java int mdelaymilles = 30000; JobScheduler jobScheduler = (JobScheduler) mActivity.getSystemService(JOB_SCHEDULER_SERVICE); ComponentName componentName = new ComponentName(mActivity, ConcurrentCheckService.class); JobInfo jobInfo = new JobInfo.Builder(JOB_ID, componentName) .setPeriodic(mdelaymilles) .setRequiredNetworkType(JobInfo.NETWORK

Android JobScheduler: using setMinimumLatency with setPeriodic

安稳与你 提交于 2019-12-14 04:20:19
问题 I'm just playing around with JobScheduler , and have a couple of niggles. One of them is that, although you can delay a job by using setMinimumLatency() , you cannot use that in combination with setPeriodic() , since an Exception is raised. I cannot really understand why this is the case... it seems to be reasonable to delay the start of a periodic job, just as it is reasonable to delay the start of a one-off job. Given that you cannot, what is the best way of scheduling a periodic job that

Guarantee that android keeps on retrieving sensor data

心不动则不痛 提交于 2019-12-14 02:51:50
问题 I'm developing an app that tracks trips. After searching about this matter, I concluded that the best way to achieve this (continuously track the user's location) is to use a foreground service. In some cases is working quite well, but in some other cases (even with DOZE off), I get some time intervals in which the phone is completely still and I stop getting sensor data (either accelerometer or locations from fused location provider). This problem got worse when I tried it in an Android 9

JobScheduler setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) not working

眉间皱痕 提交于 2019-12-13 07:17:08
问题 The following code never runs. The job is scheduled successfully however it is never actually executed. I've even set an overriding deadline of 1m10s. The device is connected to WiFi at all times and even after 5 hours of wait, I never see it launched. What am I doing wrong? int REFRESH_JOB_ID = 13; jobScheduler.cancel(REFRESH_JOB_ID); // Requires WiFi / Edge / 3G JobInfo jobInfo = new JobInfo.Builder(REFRESH_JOB_ID, componentName). setMinimumLatency(1 * 60 * 1000). setRequiredNetworkType

How to start task periodically using firebase job scheduler

匆匆过客 提交于 2019-12-12 05:37:33
问题 I used Jobschuler for sending notification every x minutes(determined dynamically) like this ComponentName componentName = new ComponentName(context,ClsJobService.class); JobInfo.Builder builder = new JobInfo.Builder(0, componentName) .setPeriodic(duration * 60 * 1000); //setting in millisecond JobScheduler jobScheduler = (JobScheduler) context.getSystemService (Context.JOB_SCHEDULER_SERVICE); jobScheduler.schedule(builder.build()); and its working great it sends notification on time defined

android-job: Periodic once a day, DeviceIdle = true, as soon as possible

社会主义新天地 提交于 2019-12-12 01:52:44
问题 need some help to set up my perodic job correctly with android-job lib. I want to start a job once a day and the device is ideling. Additionally the job should start as soon as possible on day. That means in best way the job start at 00:01 AM. And it's not that solution descriped here! Is this possible? Can anyone give me a hint for the rigth solution? Here is my code snippset for a Job once a day if device is idle mJobId = new JobRequest.Builder(JOBTAG) .setPeriodic(TimeUnit.HOURS.toMillis

Why is Network access in my geofence broadcast receiver unreliable?

不羁岁月 提交于 2019-12-11 13:44:37
问题 Use case: When geofence triggers we need to contact server ASAP. We have solved this with an implicit BroadcastReceiver calling a Service for several years, but problematic in new versions due to Doze and Oreo background restrictions. Attempted fixes: We moved geofence registering from implicit -> explicit broadcast receiver to get around the "background mode" restriction. We tried to do it as in Googles examples, i.e. the broadcast receiver calling enqueueWork() on a JobIntentService . The

Pass context to JobService Android JobScheduler

帅比萌擦擦* 提交于 2019-12-10 22:13:30
问题 I am building an app where I store the url and Json in my local SQLite db and then schedule a JobService. In the JobService, I take out all the requests one by one from the db and execute them. Once they are executed, I get the response inside the JobService only. Now my real problem is how do I send the response back to the user from the service. I thought of implementing a callback/listener in activity and passing the value in listener object inside the service. But I am taking out the