Android: How can I completely abort/remove sticky broadcast

和自甴很熟 提交于 2019-12-19 03:13:59

问题


We can remove an ordered broadcast with abortBroadcast(), is there a way to completely remove a sticky ordered broadcast?


回答1:


removeStickyBroadcast is exactly what you need:

public abstract void removeStickyBroadcast (Intent intent)

Since: API Level 1

Remove the data previously sent with sendStickyBroadcast(Intent), so that it is as if the sticky broadcast had never happened.

You must hold the BROADCAST_STICKY permission in order to use this API. If you do not hold that permission, SecurityException will be thrown.

Parameters

intent The Intent that was previously broadcast.

http://developer.android.com/reference/android/content/Context.html#removeStickyBroadcast(android.content.Intent)



来源:https://stackoverflow.com/questions/11839043/android-how-can-i-completely-abort-remove-sticky-broadcast

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