Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No more words,look at these codes.You should listen the <strong>PhoneStateListener's CALL_STATE_OFFHOOK</strong> and call the <strong>setHandsetPhone()</strong> at a delay time.</p> <pre><code>private void setHandsetPhone() { if (isBluetoothAvailable() &amp;&amp; isBluetoothAudioConnected()) { disconnectBluetoothAudio(); } //am == AudioManager if (am.isSpeakerphoneOn()) { am.setSpeakerphoneOn(false); } } private boolean isBluetoothAvailable() { printLog("isBluetoothAvailable()..."); // Check if there's a connected headset, using the BluetoothHeadset API. boolean isConnected = false; if (mBluetoothHeadset != null) { List&lt;BluetoothDevice&gt; deviceList = mBluetoothHeadset.getConnectedDevices(); if (deviceList.size() &gt; 0) { isConnected = true; } } return isConnected; } /** * @return true if a BT Headset is available, and its audio is currently * connected. */ private boolean isBluetoothAudioConnected() { if (mBluetoothHeadset == null) { return false; } List&lt;BluetoothDevice&gt; deviceList = mBluetoothHeadset.getConnectedDevices(); if (deviceList.isEmpty()) { return false; } BluetoothDevice device = deviceList.get(0); boolean isAudioOn = mBluetoothHeadset.isAudioConnected(device); return isAudioOn; } private void disconnectBluetoothAudio() { if (mBluetoothHeadset != null) { Class clazz = mBluetoothHeadset.getClass(); try { Method method = clazz.getMethod("disconnectAudio", new Class[] {}); System.out.println("result-" + method.invoke(mBluetoothHeadset)); } catch (Exception e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload