Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I query GcmNetworkManager to see if my task is scheduled or not?

I have scheduled a task to run periodically using GcmNetworkManager, but I don't want it to be persisted, because I don't want to add android.Manifest.permission.RECEIVE_BOOT_COMPLETED to list of the permissions my application requires. So, I am currently scheduling the task in onCreate() of my main activity. I was wondering, is there a way to query GcmNetworkManager about my task and if it has already been scheduled, skip this?

like image 755
iMan Biglari Avatar asked Oct 30 '22 04:10

iMan Biglari


1 Answers

There is method in Task.Builder called setUpdateCurrent(link). It is optional setter to specify whether this task should override any preexisting tasks with the same tag. This defaults to false, which means that a new task will not override an existing one.

Hope it helps

like image 53
busylee Avatar answered Nov 15 '22 05:11

busylee