android-jobscheduler

Android: How to use JobFinished of JobService

徘徊边缘 提交于 2019-12-09 03:36:41
问题 I didn't see example of using jobFinshed of JobService, seems like we have to track changes when some condition meet we have to call jobFinished() method, am I right? 回答1: The difficulty of calling jobFinished() from another class like an IntentService seems to be getting an instance of your class that extends JobService to use to call jobFinished() . You can get info on the scheduled job, but not on the JobService (at least, I can't find a way). I can think of 3 ways to call jobFinished() .

Android Priority-Job-Queue keep retrying until success

强颜欢笑 提交于 2019-12-08 11:39:28
问题 So I have to download a bunch of image files from a server and I'm using Priority-Job-Queue. So far seems to works fine and I'm using a simple AsyncTask for the downloading part. Since I want the images to be downloaded no matter what I only added RetryConstraint.RETRY on shouldReRunOnThrowable() callback. I have also added android.permission.RECEIVE_BOOT_COMPLETED permission on Manifest.xml Is this the right/best way so if there's any kind of problem and some images aren't downloaded due to

Android Wake lock remains after Doze mode?

倖福魔咒の 提交于 2019-12-08 07:19:00
问题 Iam trying to simulate the Doze mode while my app is running in the background. What happens is that the thread will continue to run, even though the device has entered Doze mode. The docs specifies that wake locks are ignored, so why cpu is still on? Tested On: Emulator with Api 27 JobScheduler jobScheduler = (JobScheduler)getApplicationContext() .getSystemService(JOB_SCHEDULER_SERVICE); ComponentName componentName = new ComponentName(this, MyJob.class); JobInfo jobInfo = new JobInfo.Builder

GCM Network Manager - Periodic Task not firing

喜你入骨 提交于 2019-12-07 03:24:16
问题 I'm attempting to use the GcmNetworkManager to schedule a recurring task in my app, which runs down to API level 17. I've set everything up as explained on the GCM Network Manager page (https://developers.google.com/cloud-messaging/network-manager): In my AndroidManifest.xml, I have: <service android:name=".services.MyService" android:exported="true" android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"> <intent-filter> <action android:name="com.google.android.gms

JobScheduler: controlling delay from constraints being met to job being run

混江龙づ霸主 提交于 2019-12-06 17:01:02
问题 I'm using JobScheduler to schedule jobs. Mainly I'm using it for the .setRequiredNetworkType() method, which allows you to specify that you only want the job to be scheduled when a network connection (or more specifically an unmetered connection) is established. I'm using the following pretty straightforward code to schedule my jobs: PersistableBundle extras = new PersistableBundle(); extras.putInt("anExtraInt", someInt); int networkConstraint = useUnmetered ? JobInfo.NETWORK_TYPE_UNMETERED :

JobScheduler for Nougat/Oreo

不想你离开。 提交于 2019-12-06 14:29:08
问题 I followed some online tutorials about jobscheduling in android and I tried doing it and found out that the below code compiles without errors. But the problem is there is no toast from the onPostExecute/doInBackground return message. Is there anything that might be required? Its like I just run the code and placed some toasts and notice that myScheduler.schedule(myjobInfo); works, background tasks is carrying out. my gradle file is not touched at all compileSdkVersion 26 defaultConfig {

Unable to implement callback in Android

狂风中的少年 提交于 2019-12-05 21:44:39
I am building an SDK. The Scenario From the app, the developer passes the JsonObject and URL in a method and inside the SDK. I add those values in SQLite database and start a JobScheduler. The Jobscheduler takes the request at 0 indexes out of the database executes it. When I get the response, I delete that request from the database and now the request at 1 index comes to the 0 index and again I execute the same code where 0th index request is fired. The Problem When I get the response from a server inside the SDK, I need to send it to the developer using a callback. I can take the callback as

Android jobScheduler won't stop with jobFinished(params, false)

喜你入骨 提交于 2019-12-05 18:10:01
问题 I'm tring to create a jobService. Here is what onStartJob() looks like. @Override public boolean onStartJob(JobParameters params) { Log.d(TAG, "onStartJob"); Log.d(TAG, "Params= " + params.getJobId()); param = params; jobFinished(params, false); //startAsync(); return true; } @Override public boolean onStopJob(JobParameters params) { Log.d(TAG, "onStopJob"); return false; } Here is the code that is supposed to start the job. public void startJobScheduler(){ Log.d(TAG, "inside

How to Detect network disconnection in Firebase Job dispatcher?

和自甴很熟 提交于 2019-12-05 10:50:36
In firebase Job dispatcher its possible to detect when we connect to a network, but how to detect when we disconnect from a network? Job myJob = dispatcher.newJobBuilder() .setService(MyJobService.class) .setTag("my-unique-tag") .setConstraints( // only run on an unmetered network Constraint.ON_UNMETERED_NETWORK, // only run when the device is charging Constraint.DEVICE_CHARGING ) .build(); dispatcher.mustSchedule(myJob); This will detect when connected to Unmetrered Network , i want to start a service whenever it is disconnected from all networks Using firebase dispatcher you can't check the

GCM Network Manager - Periodic Task not firing

◇◆丶佛笑我妖孽 提交于 2019-12-05 08:22:56
I'm attempting to use the GcmNetworkManager to schedule a recurring task in my app, which runs down to API level 17. I've set everything up as explained on the GCM Network Manager page ( https://developers.google.com/cloud-messaging/network-manager ): In my AndroidManifest.xml, I have: <service android:name=".services.MyService" android:exported="true" android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"> <intent-filter> <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/> </intent-filter> </service> In my Application, I have: long periodSecs = 30L;