JobScheduler - How do I determine a unique Job ID?

不问归期 提交于 2019-12-04 10:01:32

问题


According to the documentation, jobs must have a unique Job ID per uid.
If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs? If so, how can I avoid these kind of collisions?


回答1:


If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs?

Correct.

If so, how can I avoid these kind of collisions?

Ask the developer of the library what job IDs they use, or if those job IDs are configurable somehow.




回答2:


If asking the developer of library doesn't work, you may want to calculate md5 on package name and pick last 4 bytes as unique id. The chances of collision will be quite less.



来源:https://stackoverflow.com/questions/44414771/jobscheduler-how-do-i-determine-a-unique-job-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!