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


Java BluetoothAdapter.STATE_CONNECTED属性代码示例

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


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

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "blueConnectStateBroadcastReceiver action>>>>" + intent.getAction());
    if (intent.getAction() == null)
        return;
    if (intent.getAction().equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
        int blueconState = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, 0);
        switch (blueconState) {
            case BluetoothAdapter.STATE_CONNECTED:
                Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_CONNECTED");
                voiceMediator.setBlueHeadSet(true);
                isBlueToothHeadsetConnected();
                break;
            case BluetoothAdapter.STATE_CONNECTING:
                Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_CONNECTING");
                break;
            case BluetoothAdapter.STATE_DISCONNECTED:
                Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_DISCONNECTED");
                voiceMediator.setBlueHeadSet(false);
                voiceMediator.setSuportA2DP(false);
                AudioManager mAudioManager_ = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                mAudioManager_.setBluetoothScoOn(false);
                mAudioManager_.stopBluetoothSco();
                break;
            case BluetoothAdapter.STATE_DISCONNECTING:
                Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_DISCONNECTING");
                voiceMediator.setSuportA2DP(false);
                break;
            default:
                break;
        }
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:33,代码来源:AssistantService.java

示例2: onConnectionStateChanged

@Override
public void onConnectionStateChanged(Connection connection, int newState) {
    if (connectionStateListener != null) {
        connectionStateListener.onConnectionStateChanged(connection, newState);
    }

    if (newState == BluetoothAdapter.STATE_DISCONNECTED) {
        NeatleLogger.d("Will try to reconnect to " + connection.getDevice().getAddress() + " after " + (reconnectTimeout / 1000) + " seconds");

        handler.removeCallbacks(reconnectRunnable);
        handler.postDelayed(reconnectRunnable, reconnectTimeout);
        reconnectTimeout = Math.min(reconnectTimeout * 2, MAX_RECONNECT_TIMEOUT);
    } else if (newState == BluetoothAdapter.STATE_CONNECTED) {
        reconnectTimeout = DEFAULT_RECONNECT_TIMEOUT;
    }
}
 
开发者ID:inovait,项目名称:neatle,代码行数:16,代码来源:ConnectionMonitorImpl.java

示例3: updateBtIconVisibility

private void updateBtIconVisibility() {
    if (mSbService == null || mBtMode == null) return;

    try {
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
        if (btAdapter != null) {
            boolean enabled = btAdapter.getState() == BluetoothAdapter.STATE_ON;
            boolean connected = (Integer) XposedHelpers.callMethod(btAdapter, "getConnectionState") ==
                    BluetoothAdapter.STATE_CONNECTED;
            boolean visible;
            switch (mBtMode) {
                default:
                case DEFAULT: visible = enabled; break;
                case CONNECTED: visible = connected; break;
                case HIDDEN: visible = false; break;
            }
            if (DEBUG) log("updateBtIconVisibility: enabled=" + enabled + "; connected=" + connected +
                    "; visible=" + visible);
            XposedHelpers.callMethod(mSbService, "setIconVisibility", "bluetooth", visible);
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:24,代码来源:SystemIconController.java

示例4: isBTHeadsetConnected

@Override
public boolean isBTHeadsetConnected() {
    if(bluetoothAdapter != null) {
        return (bluetoothAdapter.getProfileConnectionState(BluetoothProfile.HEADSET) == BluetoothAdapter.STATE_CONNECTED);
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:7,代码来源:BluetoothUtils14.java

示例5: 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

示例6: 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

示例7: onConnectionStateChanged

@Override
public void onConnectionStateChanged(Connection connection, int newState) {
    if (newState == BluetoothAdapter.STATE_CONNECTED) {
        subscribeOnDevice();
    }
}
 
开发者ID:inovait,项目名称:neatle,代码行数:6,代码来源:CharacteristicSubscriptionImpl.java


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