Most visited

Recently visited

LocalBroadcastManager

public final class LocalBroadcastManager
extends Object

java.lang.Object
   ↳ android.support.v4.content.LocalBroadcastManager


帮助者注册并发送Intents广播到您的流程中的本地对象。 与使用sendBroadcast(Intent)发送全球广播相比,这具有许多优势:

Summary

Public methods

static LocalBroadcastManager getInstance(Context context)
void registerReceiver(BroadcastReceiver receiver, IntentFilter filter)

注册接收任何与给定IntentFilter匹配的本地广播。

boolean sendBroadcast(Intent intent)

将给定的意图广播给所有感兴趣的BroadcastReceivers。

void sendBroadcastSync(Intent intent)

sendBroadcast(Intent)一样,但是如果有任何Intent的接收器,这个函数将会阻塞,并在返回之前立即调度它们。

void unregisterReceiver(BroadcastReceiver receiver)

取消注册以前注册的BroadcastReceiver。

Inherited methods

From class java.lang.Object

Public methods

getInstance

LocalBroadcastManager getInstance (Context context)

Parameters
context Context
Returns
LocalBroadcastManager

registerReceiver

void registerReceiver (BroadcastReceiver receiver, 
                IntentFilter filter)

注册接收任何与给定IntentFilter匹配的本地广播。

Parameters
receiver BroadcastReceiver: The BroadcastReceiver to handle the broadcast.
filter IntentFilter: Selects the Intent broadcasts to be received.

也可以看看:

sendBroadcast

boolean sendBroadcast (Intent intent)

将给定的意图广播给所有感兴趣的BroadcastReceivers。 这个调用是异步的; 它会立即返回,并且您将在接收器运行时继续执行。

Parameters
intent Intent: The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
Returns
boolean

也可以看看:

sendBroadcastSync

void sendBroadcastSync (Intent intent)

sendBroadcast(Intent)一样,但是如果有任何Intent的接收器,这个函数将会阻塞并在返回之前立即发送它们。

Parameters
intent Intent

unregisterReceiver

void unregisterReceiver (BroadcastReceiver receiver)

取消注册以前注册的BroadcastReceiver。 所有为此BroadcastReceiver注册的过滤器都将被删除。

Parameters
receiver BroadcastReceiver: The BroadcastReceiver to unregister.

也可以看看:

Hooray!