Wish Firebase JobDispatcher

Multiverse app

Active Member
Licensed User
Longtime User
Firebase JobDispatcher API is a backward compatible implementation of JobScheduler, to help reduce the app's dependency on background process and alleviate strain on the device's resources. Firebase JobDispatcher/JobScheduler are the APIs designed for scheduling various types of jobs against the framework that will be executed in your application's own process. If your app has any foreground services (e.g. playing music), the situation may not apply. If the app does not have any background process, this suggestion may not apply. In general, try to avoid long-running background process in the app. Even if the app doesn't have many background operations, accumulatively with other apps, they can use up battery life and cause devices to become less responsive.

Why is this better than background services and listening for system broadcasts?
Running apps in the background is expensive, which is especially harmful when they're not actively doing work that's important to the user. That problem is multiplied when those background services are listening for frequently sent broadcasts (android.net.conn.CONNECTIVITY_CHANGE and android.hardware.action.NEW_PICTURE are common examples). Even worse, there's no way of specifying prerequisites for these broadcasts. Listening for CONNECTIVITY_CHANGE broadcasts does not guarantee that the device has an active network connection, only that the connection was recently changed.

In recognition of these issues, the Android framework team created the JobScheduler. This provides developers a simple way of specifying runtime constraints on their jobs. Available constraints include network type, charging state, and idle state.

This library uses the scheduling engine inside Google Play services(formerly the GCM Network Manager component) to provide a backwards compatible (back to Gingerbread) JobScheduler-like API.

This I/O presentation has more information on why background services can be harmful and what you can do about them:




https://github.com/firebase/firebase-jobdispatcher-android (FirebaseJobDispatcher)
https://developer.android.com/reference/android/app/job/JobScheduler.html (JobScheduler)
 

DonManfred

Expert
Licensed User
Longtime User
I think the JobDispathcer is a good thing but i fear that you need to write your own Service which extends their JobService
Inside the JobBuilder you need to define the Class of your Service which, as i wrote, must extend the JobService.
Inside this service (must be written in java) you need to answer things about the Job which us about to raise. Or something like that...
the Point is that it is this Service which answers if a Job should be rescheduled and so....

I don´t know if it is possible to raise an Event inside a java-service to B4A which then get the result (true/false) inside this event back from B4A.
Probably used inside the starter-service then... I need to investigate first ;)

Just my 2cent.
 
Top