Code example for BluetoothAdapter

Methods: enable, isEnabled

0
		active = prefs.getBoolean("activated", false);
		if (active){
			switch(state){
				case TelephonyManager.CALL_STATE_RINGING:
					Log.i(TAG, "Phone is ringing.");
					if(!btAdapter.isEnabled()){
						btAdapter.enable();
					} 
					break; 
				case TelephonyManager.CALL_STATE_IDLE:
					Log.i(TAG, "Phone call ended.");
					if(btAdapter.isEnabled()){
						btAdapter.disable();
					} 
					break; 
				case TelephonyManager.CALL_STATE_OFFHOOK:
					Log.i(TAG, "Placing phone call.");
					if(!btAdapter.isEnabled()){
						btAdapter.enable();
					} 
					break; 
				default: 
					break; 
			}