2

Android Shortcuts无法添加或者更新

 2 years ago
source link: https://blog.csdn.net/ljphhj/article/details/118415435
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Android Shortcuts无法添加或者更新

original.png
胖虎 2021-07-02 14:50:18 34
分类专栏: Android知识点

安卓系统源码里做了API节流,只允许app在后台调用:

android.content.pm.ShortcutManager#addDynamicShortcuts
android.content.pm.ShortcutManager#updateShortcuts
android.content.pm.ShortcutManager#setDynamicShortcut

合起来的总调用次数不超过10次,超过10次将不会成功执行。

当App回到前台后,计数器会清0,重新开始10次的计算。

如果你的app需要在后台频繁更新shortcuts,请注意这个问题。适当做判断优化,若shortcuts label没更新的请不要调用update接口。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK