安卓:我怎样才能彻底中止/删除持久广播 [英] Android: How can I completely abort/remove sticky broadcast

查看:749
本文介绍了安卓:我怎样才能彻底中止/删除持久广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以删除与abortBroadcast()一个有序的广播,有没有办法彻底清除粘有序的广播?

解决方案

removeStickyBroadcast 正是你所需要的:

 公共抽象无效removeStickyBroadcast(意向意图)
 

  

由于:API级别1

     

删除数据$ P $与 sendStickyBroadcast pviously发送(意向),这样就好像粘广播从来没有发生过。

     

您必须持有 BROADCAST_STICKY 许可才能使用这个API。如果你不持有该权限,则抛出SecurityException。

     

参数

     

意图的,这是previously广播的意图。

<一个href="http://developer.android.com/reference/android/content/Context.html#removeStickyBroadcast(android.content.Intent">http://developer.android.com/reference/android/content/Context.html#removeStickyBroadcast(android.content.Intent)

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

解决方案

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)

这篇关于安卓:我怎样才能彻底中止/删除持久广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆