Wish Android Job Scheduler

Peter Simpson

Expert
Licensed User
Longtime User
The title says it all.

A nice and easy way to implement Android Job Scheduler, please see this link https://developer.android.com/about/versions/oreo/background.html#overview.

I have a strange feeling that you're going to say use a notifications to add a icon at the top of the screen to keep the service running

Please note that I personally do not actually need this feature as none of my apps are effected. But I've come across a post and while testing in Android V8.1.0 I realised that there might be an issue in the future that does not effect me right now, phew. Maybe it's something that you already know a logical workaround for (without adding a notification icon to the notification area).

Anyway, it's just a though...
 

DonManfred

Expert
Licensed User
Longtime User

DonManfred

Expert
Licensed User
Longtime User
I didn't even realise that there was a library until @XbNnX_507 mentioned it...
me too. I started to do a wrap for the Android Job sheduler (this thread). But i failed
I give it another go on the posted lib....
 

DonManfred

Expert
Licensed User
Longtime User
I think it is mandatory to create own (specialized) JOBCreator-Classes to use this Library...

B4X:
public class DemoJobCreator implements JobCreator {

    @Override
    @Nullable
    public Job create(@NonNull String tag) {
        switch (tag) {
            case DemoSyncJob.TAG:
                return new DemoSyncJob();
            default:
                return null;
        }
    }
}

After that you can start scheduling jobs.

B4X:
public class DemoSyncJob extends Job {

    public static final String TAG = "job_demo_tag";

    @Override
    @NonNull
    protected Result onRunJob(Params params) {
        // run your job here
        return Result.SUCCESS;
    }

    public static void scheduleJob() {
        new JobRequest.Builder(DemoSyncJob.TAG)
                .setExecutionWindow(30_000L, 40_000L)
                .build()
                .schedule();
    }
}

in this case the creator will always create a specific Job which we, the developers, need to use in the java project....

I´m not sure if it will work with a simple wrapper for this. We´ll see...
Hopefully i can post a 1st version to test today
 

DonManfred

Expert
Licensed User
Longtime User
It is partially working as of now...


i also can see more info in the unfiltered log


But the event to run the job does not raise. I need to investigate more....
 

dcoun

Member
Licensed User
Longtime User
Not sure. It will take some time for this feature to be added and it will probably won't be a "job scheduler library" but rather a more flexible way to work with receivers and how they interact with services.
Hi, do we have a roadmap for that?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…