动态设置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" ) ) { // ... } } };

    原文作者:ydpl2007
    原文地址: https://blog.csdn.net/ydpl2007/article/details/7560547
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞