IntentFilter filter = new IntentFilter( );
filter.addAction( “Action1” );
filter.addAction( “Action2” );
mContext.registerReceiver( receiver, filter );
// 定义一个receiver
private BroadcastReceiver receiver = new BroadcastReceiver( ) {
@Override
public void onReceive( Context context, Intent intent ) {
String action = intent.getAction( );
if( action.equals( "action1" ) ) {
// ... } else if( action.equals( "action2" ) ) { // ... } } };