android-jobscheduler

Run service on incoming SMS in android Oreo

末鹿安然 提交于 2019-11-29 10:46:13
I'm developing an app which needs to run some code (Networking) whenever an SMS is received. In API 25 and lower it's fine, I register an implicit receiver in Manifest file and start my service in the specified class which extended BroadcastReceiver . In API 26 however you cannot register android.provider.Telephony.SMS_RECEIVED in a receiver since it won't work. From Android documentation: Note: If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for implicit broadcasts (broadcasts that do not target your app specifically), except for a few implicit

Android start running JobScheduler at specific time

浪子不回头ぞ 提交于 2019-11-29 09:26:22
问题 I want to start a JobScheduler at a specific time everyday , and finish it after 3 hours. I have the part of triggering the job every 20 min, and for 3 hours, but in JobInfo.Builder class there's no option for starting the job at an exact time. Going over the JobInfo.Builder class overview, there's nothing there that sets the time for starting a JobScheduler. Obviously, i don't want to run it for the whole day, and check that the time matches, this will drain more battery than needed, and is

JobScheduler posting Jobs twice (not expected)

跟風遠走 提交于 2019-11-29 06:16:05
I am writing a tutorial on JobScheduler and I find a strange behavior. I ask for 3 differents jobs to be scheduled in 1 second (.setOverrideDeadline(1000)) but they are all submitted and ran twice... So here the code: public class MyApplication extends Application { private static final int JOB_ID_HanlderThread = 100; private static final int JOB_ID_ExecutorService = 200; private static final int JOB_ID_AsyncTask = 300; JobScheduler mJobScheduler; ExecutorService myExecutorServiceForJobs=null; private static MyApplication INSTANCE; public static MyApplication getInstance(){ return INSTANCE; }

Some questions about GcmTaskService

风流意气都作罢 提交于 2019-11-28 23:08:29
Background I wanted to use the new JobScheduler API that was presented on Lollipop, but sadly it doesn't have an official port for pre-Lollipop. However, there is the GcmTaskService, which provides very similar functionalities. The problem This API is quite new, so there are very few places to look for information of how to use it ( here and here , for example). The questions I have a few questions about this new API : It seems that it requires Google Play Services ( here ) to be used (except for when using Lollipop version of Android, which will use the normal JobScheduler). What should I do

How to check JobService is running or not in android?

£可爱£侵袭症+ 提交于 2019-11-28 23:07:06
问题 I am using JobService in my project. It's working good. But sometimes service stopped. It is not restart again. So that I am trying to strat the JobService if not running. But I don't know how to check JobService is already running or not. Please let me any idea to how to check JobService is running or not. My Job service class: @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public class JobService extends android.app.job.JobService { @Override public boolean onStartJob(JobParameters params

Android WorkManager api for running daily task in Background

眉间皱痕 提交于 2019-11-28 09:54:15
I need to call one API daily in the background even if the app is closed. I have seen about WorkManager API. For my scenario, I tried PeriodicWorkRequest but unfortunately, it's not working as my expected result. What I did is I used this code in the Application class PeriodicWorkRequest.Builder myWorkBuilder = new PeriodicWorkRequest.Builder(MyWorker.class, 24, TimeUnit.HOURS); PeriodicWorkRequest myWork = myWorkBuilder.build(); WorkManager.getInstance().enqueue(myWork); But it's running repeatedly for 11 times when the app is open for the first time after that, it's not running after 24 hrs.

JobScheduler posting Jobs twice (not expected)

↘锁芯ラ 提交于 2019-11-27 23:42:45
问题 I am writing a tutorial on JobScheduler and I find a strange behavior. I ask for 3 differents jobs to be scheduled in 1 second (.setOverrideDeadline(1000)) but they are all submitted and ran twice... So here the code: public class MyApplication extends Application { private static final int JOB_ID_HanlderThread = 100; private static final int JOB_ID_ExecutorService = 200; private static final int JOB_ID_AsyncTask = 300; JobScheduler mJobScheduler; ExecutorService myExecutorServiceForJobs=null

Android Oreo killing background services and clears pending alarms, scheduled jobs after entering doze mode

只愿长相守 提交于 2019-11-27 23:39:50
My app has a background service running that gets users current location and update it to a server every five minutes. To run this location update process continuously, I use alarm manager to set its next execution time from the service itself. However, when I install the app in my Nokia 6 running Android 8.1 it works for some time and if I keep the phone idle for some time, my service will get killed with the next alarms by the application also being cleared from system alarm manager . My guess was that the idle time makes the phone enter doze mode . However, I don't understand why the alarm

IntentService + startForeground vs JobIntentService

偶尔善良 提交于 2019-11-27 22:37:41
问题 Since Android Oreo background execution limits, the docs recommend to refactor IntentService s to JobIntentService . https://developer.android.com/about/versions/oreo/background JobIntentService runs immediately as an IntentService below Oreo, but schedules a Job on Oreo+ https://developer.android.com/reference/android/support/v4/app/JobIntentService In what cases would it make sense to run a normal IntentService as a foreground Service with a persistent notification, and when is a

What tools are available to test JobScheduler?

核能气质少年 提交于 2019-11-27 17:17:30
We're implementing a Job via JobScheduler for background loading of data. The job will fire about once a day. What tools are available for us to test this functionality (possibly ADB)? Use cases are to be able to simulate the conditions required for a Job to be run or to just say specifically "Run this job" as part of our automated test suite. tim Right. Henning and P4u144 set me on the right track to answer this in more detail. Identify all registered jobs Identify your task with the adb shell dumpsys jobscheduler command. This will give you a huge output in following categories. Settings