jacktech24 did a really good job, but I will try too if there are any lingering questions.
It seems that this requires the use of Google Play Services (here) (except when using the Lollipop version of Android, which will use the usual JobScheduler). What should I do if Google Play services are not available? *
You cannot use this API if Google Play Services is not available. Rather, the Google Play Services client library is designed to request that the user download and install Google Play Services if they find that they are missing, but I do not think GcmNetworkManager does this.
What is the default behavior of a task if I do not use "setRequiredNetwork"? Is this "NETWORK_STATE_ANY"? *
Description of javadoc, by default.
The docs say that it returns from onRunTask, I can return any values ββ"RESULT_FAILURE", "RESULT_RESCHEDULE", "RESULT_SUCCESS" (information here). It seems that both the FAILURE and SUCCESS parameters will do the same - remove the task from the queue. It's true? If so, what is the difference between the two? Do they work differently? *
The only difference between these 2 is that the dumpsys of the adb shell will display what you returned, so you can use this for troubleshooting. Another reason is that if the task does not work, it is strange to require the client to return βsuccessβ.
Are TaskParams used only for task tags? Can I somehow pass a set of tasks using the API? Otherwise, I will need to install a database to store what should be transferred to the tasks, right? *
The next version of GmsCore needs to support the ability to add a package to a task.
Is it possible for an application to receive a task queue? I know this is possible using adb, but is it possible using the API?
No, It is Immpossible. Instead, you should cancel it whenever you want, and if there is no task, it will be no-op. Similarly, you should schedule a task at a point in your code where you would request a list of tasks. use setUpdateCurrent = false to ensure that it is not updating a preexisting task. AlarmManager works in a similar way, since you set an alarm regardless of whether an alarm has already been set - the api was designed to follow this.
They say (here) that each task has a wakelock up to 3 minutes long. What if the task requires more? Should he buy another wakelon for himself? Will the API warn about the release of wakelock? Here's what the docs say: *
Yes, the application must purchase its own wakelock, and everything will be fine. The reason the scheduler releases wakelock after 3 minutes is because in practice, the unlimited timeout of wakelock only makes it very difficult to track battery leakage errors. If you need more than 3 minutes, you have a rather complicated precedent that you can understand how PowerManager APIs work and call to independently acquire () / release () (this is really quite simple, the fact that the network manager does this because you are more polite than anything else).
They say (here) that all network tasks are deleted every time the application is updated / replaced, and when this happens, a call to "onInitializeTasks" occurs, and you can re-assign them again. How to reschedule tasks? I donβt think I can even get a list of tasks ... *
You transfer tasks just as you planned them. Whatever function you plan, call this function from GcmTaskService # onInitializeTasks. This was done in order to avoid lengthy tasks when changing application logic. Consider a situation where a developer changes the schedule of his task and starts using a different tag. They will have to cancel the cancellation (old_tag) after they find the update (which they will need to add for more code), which would mean that they need a link to the old (unused) tag even in their new code. This would mean that the tag is a stable identifier that should not change when updating applications, which should not be a requirement for this api.
Is it possible to set a preference for a specific time during the day? For example, between 14: 00-15: 00? *
No, this type of background planning causes all sorts of problems with pasture across large groups of devices. That is, if 1 device starts working at 15:00, which is probably fine. But if 1x10e6 suddenly there is a serious problem with your server.
I noticed that if you are planning a task, and then forcibly stop and / or clear the application data, the task will still be executed. How can I avoid this behavior? *
Unfortunately, you cannot, but this is not intentional and should be changed - there should be no way to launch the application after the user has explicitly stopped it.