动态设置BroadcastReceiver的IntentFilter

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" ) ) { // ... } } };



你可能感兴趣的:(String,filter,action)