本文整理匯總了Java中android.bluetooth.BluetoothAdapter.STATE_DISCONNECTING屬性的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothAdapter.STATE_DISCONNECTING屬性的具體用法?Java BluetoothAdapter.STATE_DISCONNECTING怎麽用?Java BluetoothAdapter.STATE_DISCONNECTING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.bluetooth.BluetoothAdapter
的用法示例。
在下文中一共展示了BluetoothAdapter.STATE_DISCONNECTING屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
}
}
示例2: 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";
}
}
示例3: 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";
}
}