How to request Android user to enable Bluetooth through a click?

前端 未结 2 1467
北海茫月
北海茫月 2021-02-14 11:12

from http://developer.android.com/guide/topics/connectivity/bluetooth.html i know that i need to the following to request the user to enable his BT:

if (!mBlueto         


        
2条回答
  •  天涯浪人
    2021-02-14 11:26

    Before you call the following method

    !mBluetoothAdapter.isEnabled()
    

    on the adapter, you have to make sure mBluetoothAdapter is not null. In your case it must be null and crashing. And if mBluetoothAdapter is null, the android documentation says that the device doesn't support Bluetooth.

提交回复
热议问题