我试图启用禁用蓝牙设备。因此,我在下面编写了代码,但给出了错误,该错误也在下面。
if ( bluetoothAdmin == null ) {
return ;
}
if ( bluetooth . isEnabled()){
bluetooth . disable ();
}
else {
bluetooth . enable();
}
Run Code Online (Sandbox Code Playgroud)
在创建
BLuetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter() ;
Run Code Online (Sandbox Code Playgroud)
在清单上
<uses-permission
android:name="android.permission.BLUETOOTH"
/>
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
/>
Run Code Online (Sandbox Code Playgroud)
错误:
01-23 07:18:53.167: E/BluetoothAdapter(883): Bluetooth binder is null
Run Code Online (Sandbox Code Playgroud)
一半的堆栈:
01-23 07:36:55.624: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
01-23 07:37:16.954: E/ActivityThread(642): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d51230 that was originally bound here
01-23 07:37:16.954: E/ActivityThread(642): …Run Code Online (Sandbox Code Playgroud) android ×1