Android: How can I completely abort/remove sticky broadcast

后端 未结 1 1975
野的像风
野的像风 2021-01-05 23:37

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

相关标签:
1条回答
  • 2021-01-05 23:44

    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)

    0 讨论(0)
提交回复
热议问题