广播类如下:
//蓝牙广播
public class BlueToothStateReceiver extends BroadcastReceiver {
public int DEFAULT_VALUE_BULUETOOTH = 1000;
//public OnBlueToothStateListener onBlueToothStateListener;
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, DEFAULT_VALUE_BULUETOOTH);
switch (state) {
case BluetoothAdapter.STATE_OFF://蓝牙已关闭
//onBlueToothStateListener.onStateOff();
open.setChecked(false);
break;
case BluetoothAdapter.STATE_ON://蓝牙已开启
//onBlueToothStateListener.onStateOn();
open.setChecked(true);
break;