List of usage examples for android.media AudioManager stopBluetoothSco
public void stopBluetoothSco()
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
private void updateBluetoothHeadsetState(boolean connected) { if (connected == isBtHeadsetConnected) return;/* www . jav a 2s . co m*/ isBtHeadsetConnected = connected; AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE); if (connected) am.startBluetoothSco(); else am.stopBluetoothSco(); for (StateListener l : stateListeners) l.onAudioSettingsChanged(); }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
@Override public void onDestroy() { FileLog.d("=============== VoIPService STOPPING ==============="); stopForeground(true);/* ww w .j a v a 2 s . c o m*/ stopRinging(); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout); SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE); Sensor proximity = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (proximity != null) { sm.unregisterListener(this); } if (proximityWakelock != null && proximityWakelock.isHeld()) { proximityWakelock.release(); } unregisterReceiver(receiver); if (timeoutRunnable != null) { AndroidUtilities.cancelRunOnUIThread(timeoutRunnable); timeoutRunnable = null; } super.onDestroy(); sharedInstance = null; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().postNotificationName(NotificationCenter.didEndedCall); } }); if (controller != null && controllerStarted) { lastKnownDuration = controller.getCallDuration(); updateStats(); StatsController.getInstance().incrementTotalCallsTime(getStatsNetworkType(), (int) (lastKnownDuration / 1000) % 5); if (needSendDebugLog) { String debugLog = controller.getDebugLog(); TLRPC.TL_phone_saveCallDebug req = new TLRPC.TL_phone_saveCallDebug(); req.debug = new TLRPC.TL_dataJSON(); req.debug.data = debugLog; req.peer = new TLRPC.TL_inputPhoneCall(); req.peer.access_hash = call.access_hash; req.peer.id = call.id; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { FileLog.d("Sent debug logs, response=" + response); } }); } controller.release(); controller = null; } cpuWakelock.release(); AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE); if (isBtHeadsetConnected && !playingSound) am.stopBluetoothSco(); am.setMode(AudioManager.MODE_NORMAL); am.unregisterMediaButtonEventReceiver(new ComponentName(this, VoIPMediaButtonReceiver.class)); if (haveAudioFocus) am.abandonAudioFocus(this); if (!playingSound) soundPool.release(); ConnectionsManager.getInstance().setAppPaused(true, false); }