Android 激活/停用自定义广播接收器

Android 激活/停用自定义广播接收器,android,android-fragments,broadcastreceiver,Android,Android Fragments,Broadcastreceiver,抽屉里有4个碎片 MainActivity.java (extends FragmentActicity: contains DrawerLayout) FragmentCreate.java (extends Fragment) MyStuffFragment.java (extends Fragment) ActivateFragment.java (extends Fragment) LoginFragment.java (extends Fragment) 然后,我的自定义广播接收器:

抽屉里有4个碎片

MainActivity.java (extends FragmentActicity: contains DrawerLayout)
FragmentCreate.java (extends Fragment)
MyStuffFragment.java (extends Fragment)
ActivateFragment.java (extends Fragment)
LoginFragment.java (extends Fragment)
然后,我的自定义广播接收器:

MyReceiver.java (extends BroadcastReceiver)
我正在尝试激活/停用(响应激活和停用按钮)接收者:我使用以下代码在清单中静态注册它:

    <receiver android:name="MyReceiver">
        <intent-filter>
            <action android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
            <action android:name="android.net.wifi.WIFI_STATE_CHANGE" />
            <action android:name="android.net.wifi.STATE_CHANGE" />
            <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
            <action android:name="android.bluetooth.adapter.action.ACL_CONNECTED" />
            <action android:name="android.bluetooth.adapter.action.ACL_DISCONNECTED" />
        </intent-filter>
    </receiver>
或者使其在组件启用状态启用时停止

问题是:我不知道如何过滤我希望接收者等待的动作。 我会收到wifi或蓝牙更改的通知,但我只想得到其中一个,即用户在
ActivateFragment
中选择的一个。
我如何才能通过友好方式更改接收器应该等待的操作?

我不明白蓝牙的含义;当你说“你的行动”时,你指的是像“android.net.wifi.wifi状态改变”这样的特定事件?
    //create static flag  isBluetooth=true;
    public void onReceive(Context context, Intent intent) {

       this.context = context;
         if(intent==null)
            return;
       String action = intent.getAction();
       if(action.equals("your_action"){
         isBluetooth = false;
         //do somthing
       }
       else{
         if(isBluetooth){
           // do somthing
           return;
         }
         /*do your normal stuff here*/
       }
    }

//above case is allowing you to use only one action i.e mutually exclusive.if you dont want this simply remove boolean  flag
    //create static flag  isBluetooth=true;
    public void onReceive(Context context, Intent intent) {

       this.context = context;
         if(intent==null)
            return;
       String action = intent.getAction();
       if(action.equals("your_action"){
         isBluetooth = false;
         //do somthing
       }
       else{
         if(isBluetooth){
           // do somthing
           return;
         }
         /*do your normal stuff here*/
       }
    }

//above case is allowing you to use only one action i.e mutually exclusive.if you dont want this simply remove boolean  flag