当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothAdapter.STATE_TURNING_OFF属性代码示例

本文整理汇总了Java中android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothAdapter.STATE_TURNING_OFF属性的具体用法?Java BluetoothAdapter.STATE_TURNING_OFF怎么用?Java BluetoothAdapter.STATE_TURNING_OFF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.bluetooth.BluetoothAdapter的用法示例。


在下文中一共展示了BluetoothAdapter.STATE_TURNING_OFF属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: btEnable

@Rpc(description = "Enable bluetooth with a 30s timeout.")
public void btEnable() throws BluetoothAdapterSnippetException, InterruptedException {
    if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
        return;
    }
    // If bt is trying to turn off, wait for that to finish before continuing.
    if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_TURNING_OFF) {
        if (!Utils.waitUntil(
                () -> mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF,
                TIMEOUT_TOGGLE_STATE)) {
            Log.e(String.format("BT failed to stabilize after %ss.", TIMEOUT_TOGGLE_STATE));
        }
    }
    if (!mBluetoothAdapter.enable()) {
        throw new BluetoothAdapterSnippetException("Failed to start enabling bluetooth");
    }
    if (!Utils.waitUntil(() -> mBluetoothAdapter.isEnabled(), TIMEOUT_TOGGLE_STATE)) {
        throw new BluetoothAdapterSnippetException(
                String.format("Bluetooth did not turn on within %ss.", TIMEOUT_TOGGLE_STATE));
    }
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:21,代码来源:BluetoothAdapterSnippet.java

示例2: BluetoothControl20

public BluetoothControl20() {
	// cache adaptor
	mAdapter = BluetoothAdapter.getDefaultAdapter();

	if (mAdapter == null) throw new UnsupportedOperationException("No default bluetooth adapter");
	
	// initialize state
 BLUETOOTH_STATE_UNKNOWN = -1;
 BLUETOOTH_STATE_OFF = BluetoothAdapter.STATE_OFF;
 BLUETOOTH_STATE_TURNING_ON = BluetoothAdapter.STATE_TURNING_ON;
 BLUETOOTH_STATE_ON = BluetoothAdapter.STATE_ON;
 BLUETOOTH_STATE_TURNING_OFF = BluetoothAdapter.STATE_TURNING_OFF;
 
 BLUETOOTH_ACTION_STATE_CHANGED = BluetoothAdapter.ACTION_STATE_CHANGED;
 BLUETOOTH_EXTRA_STATE = BluetoothAdapter.EXTRA_STATE;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:16,代码来源:BluetoothSettingHandler.java

示例3: handleUpdateState

@Override
public void handleUpdateState(Object state, Object arg) {
    mState.visible = true;
    mState.booleanValue = false;

    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

    int btState = adapter == null ? BluetoothAdapter.ERROR : adapter.getState();
    if (isInErrorState(btState)) {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_error);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    } else if (btState == BluetoothAdapter.STATE_TURNING_ON ||
            btState == BluetoothAdapter.STATE_TURNING_OFF) {
        mState.label = "---";
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    } else if (btState == BluetoothAdapter.STATE_ON && isTetheringOn()) {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_on);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_on);
        mState.booleanValue = true;
    } else {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_off);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    }

    super.handleUpdateState(state, arg);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:26,代码来源:BluetoothTetheringTile.java

示例4: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();

    if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
        final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
        switch (state) {
            case BluetoothAdapter.STATE_OFF:
            case BluetoothAdapter.STATE_TURNING_OFF:
            case BluetoothAdapter.STATE_TURNING_ON:
                stopBluetooth();
                break;
            case BluetoothAdapter.STATE_ON:
                startBluetooth();
                break;
        }
    }
}
 
开发者ID:RomascuAndrei,项目名称:BTNotifierAndroid,代码行数:18,代码来源:Server.java

示例5: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case BluetoothAdapter.ACTION_STATE_CHANGED:
            int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
            switch (state) {
                case BluetoothAdapter.STATE_TURNING_ON:// 蓝牙打开中

                    break;
                case BluetoothAdapter.STATE_ON:// 蓝牙打开完成

                    break;
                case BluetoothAdapter.STATE_TURNING_OFF:// 蓝牙关闭中

                    break;
                case BluetoothAdapter.STATE_OFF:// 蓝牙关闭完成

                    break;
                default:
                    break;
            }
        default:
            break;
    }
}
 
开发者ID:RockyQu,项目名称:BluetoothKit,代码行数:25,代码来源:BluetoothReceiver.java

示例6: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	Log.d(LOG_TAG, "onReceive");
	final String action = intent.getAction();

	String stringState = "";
	if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
		final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
				BluetoothAdapter.ERROR);
		switch (state) {
			case BluetoothAdapter.STATE_OFF:
				stringState = "off";
				break;
			case BluetoothAdapter.STATE_TURNING_OFF:
				stringState = "turning_off";
				break;
			case BluetoothAdapter.STATE_ON:
				stringState = "on";
				break;
			case BluetoothAdapter.STATE_TURNING_ON:
				stringState = "turning_on";
				break;
		}
	}

	WritableMap map = Arguments.createMap();
	map.putString("state", stringState);
	Log.d(LOG_TAG, "state: " + stringState);
	sendEvent("BleManagerDidUpdateState", map);
}
 
开发者ID:lenglengiOS,项目名称:react-native-blue-manager,代码行数:30,代码来源:BleManager.java

示例7: stateToString

/**
 * Converts BluetoothAdapter states into local string representations.
 */
private String stateToString(int state) {
    switch (state) {
        case BluetoothAdapter.STATE_DISCONNECTED:
            return "DISCONNECTED";
        case BluetoothAdapter.STATE_CONNECTED:
            return "CONNECTED";
        case BluetoothAdapter.STATE_CONNECTING:
            return "CONNECTING";
        case BluetoothAdapter.STATE_DISCONNECTING:
            return "DISCONNECTING";
        case BluetoothAdapter.STATE_OFF:
            return "OFF";
        case BluetoothAdapter.STATE_ON:
            return "ON";
        case BluetoothAdapter.STATE_TURNING_OFF:
            // Indicates the local Bluetooth adapter is turning off. Local clients should immediately
            // attempt graceful disconnection of any remote links.
            return "TURNING_OFF";
        case BluetoothAdapter.STATE_TURNING_ON:
            // Indicates the local Bluetooth adapter is turning on. However local clients should wait
            // for STATE_ON before attempting to use the adapter.
            return "TURNING_ON";
        default:
            return "INVALID";
    }
}
 
开发者ID:nhancv,项目名称:nc-android-webrtcpeer,代码行数:29,代码来源:BluetoothManager.java

示例8: newStateDetected

private void newStateDetected(int state) {
    bluetoothState = state;
    switch (state) {
        case BluetoothAdapter.STATE_OFF:
            //Indicates the local Bluetooth adapter is off.
            break;

        case BluetoothAdapter.STATE_TURNING_ON:
            //Indicates the local Bluetooth adapter is turning on. However local clients should wait for STATE_ON before attempting to use the adapter.
            break;

        case BluetoothAdapter.STATE_ON:
            //Indicates the local Bluetooth adapter is on, and ready for use.
            break;

        case BluetoothAdapter.STATE_TURNING_OFF:
            if (!Pandwarf.getInstance().isConnected()) {
                return;
            }
            killAllProcess(new GollumCallbackGetBoolean() {
                @Override
                public void done(boolean b) {
                    EventBus.getDefault().postSticky(new StateEvent(DISCONNECTED, ""));
                }
            });
            //Indicates the local Bluetooth adapter is turning off. Local clients should immediately attempt graceful disconnection of any remote links.
            break;
    }
}
 
开发者ID:GRnice,项目名称:PandwarfDefenderProject,代码行数:29,代码来源:Main2Activity.java

示例9: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	String action = intent.getAction();
	if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)){
		if (isProtected()){
			BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
			if (device.getAddress().equals(mBTDevice.getAddress())){
				request(AntiTheftService.REQUEST_START_ALARM, null);
				if (!setSP.isAntiTheftOpenBTEnhancedMode()){
					request(AntiTheftService.REQUEST_STOP_PROTECT, null);
					request(AntiTheftService.REQUEST_SHOW_MSG, "已绑定蓝牙设备已断开连接,蓝牙防盗服务已自动关闭.");
					onProgress(AntiTheftService.MSG_REFESH_VIEWS, null);
				}
			}
		}
	}else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){
		int currState = intent.getExtras().getInt(BluetoothAdapter.EXTRA_STATE);
		int previusState = intent.getExtras().getInt(BluetoothAdapter.EXTRA_PREVIOUS_STATE);
		if ((previusState == BluetoothAdapter.STATE_ON) && (currState == BluetoothAdapter.STATE_TURNING_OFF)){
			//蓝牙已被主动关闭
			if (setSP.isAntiTheftBTClosedAlarm()){
				request(AntiTheftService.REQUEST_START_ALARM, null);
			}
			request(AntiTheftService.REQUEST_STOP_PROTECT, null);
			request(AntiTheftService.REQUEST_SHOW_MSG,"蓝牙已被关闭,蓝牙防盗服务已自动关闭!");
			onProgress(AntiTheftService.MSG_REFESH_VIEWS, null);
		}
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:29,代码来源:BTProtector.java

示例10: stateToString

/** Converts BluetoothAdapter states into local string representations. */
private String stateToString(int state) {
  switch (state) {
    case BluetoothAdapter.STATE_DISCONNECTED:
      return "DISCONNECTED";
    case BluetoothAdapter.STATE_CONNECTED:
      return "CONNECTED";
    case BluetoothAdapter.STATE_CONNECTING:
      return "CONNECTING";
    case BluetoothAdapter.STATE_DISCONNECTING:
      return "DISCONNECTING";
    case BluetoothAdapter.STATE_OFF:
      return "OFF";
    case BluetoothAdapter.STATE_ON:
      return "ON";
    case BluetoothAdapter.STATE_TURNING_OFF:
      // Indicates the local Bluetooth adapter is turning off. Local clients should immediately
      // attempt graceful disconnection of any remote links.
      return "TURNING_OFF";
    case BluetoothAdapter.STATE_TURNING_ON:
      // Indicates the local Bluetooth adapter is turning on. However local clients should wait
      // for STATE_ON before attempting to use the adapter.
      return  "TURNING_ON";
    default:
      return "INVALID";
  }
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:27,代码来源:AppRTCBluetoothManager.java

示例11: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	Log.d(LOG_TAG, "onReceive");
	final String action = intent.getAction();

	String stringState = "";
	if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
		final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
				BluetoothAdapter.ERROR);
		switch (state) {
			case BluetoothAdapter.STATE_OFF:
				stringState = "off";
				break;
			case BluetoothAdapter.STATE_TURNING_OFF:
				stringState = "turning_off";
				break;
			case BluetoothAdapter.STATE_ON:
				stringState = "on";
				break;
			case BluetoothAdapter.STATE_TURNING_ON:
				stringState = "turning_on";
				break;
		}
	}

	WritableMap map = Arguments.createMap();
	map.putString("state", stringState);
	Log.d(LOG_TAG, "state: " + stringState);
	sendEvent("BleAdminDidUpdateState", map);
}
 
开发者ID:YbrainInc,项目名称:react-native-ble-quick-sdk,代码行数:30,代码来源:BleAdmin.java

示例12: onReceive

@Override
public void onReceive(final Context context, final Intent intent) {
    final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);

    if (state == BluetoothAdapter.STATE_TURNING_OFF || state == BluetoothAdapter.STATE_OFF) {
        log.info("bluetooth was turned off, stopping service");

        stopSelf();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:AcceptBluetoothService.java

示例13: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equalsIgnoreCase(BluetoothAdapter.ACTION_STATE_CHANGED)) {
        switch (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
            case BluetoothAdapter.STATE_ON:
                BluetoothSyncService.startOrPromptBluetooth(context);
                break;
            case BluetoothAdapter.STATE_TURNING_OFF:
            case BluetoothAdapter.STATE_OFF:
                Intent stopSyncServiceIntent = new Intent(context, BluetoothSyncService.class);
                context.stopService(stopSyncServiceIntent);
                break;
        }
    }
}
 
开发者ID:aarmea,项目名称:noise,代码行数:15,代码来源:BluetoothSyncServiceManager.java


注:本文中的android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。