android - Lint error in getting Bluetooth adapter -


I'm following the documentation for bluetooth low energy devices to scan BLE devices.

As the doctor, I defined ---

  Bluetooth adapter mblluetoothAdapter = null; Last BluetoothManager bluetoothManager = (Bluetooth Manager) getSystemService (Event.BULUETOOTH_SERVICE); MBluetoothAdapter = bluetoothManager.getAdapter (); // lint error ..   

but I am getting a lint error ---

The API level 18 for the call (current is the minimum 8 ): Android .bluetooth.bluetoothManager #getAdapter

So I changed my code -

  mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter ();   

What is the code replacement for the above lint error?

You can call BluetoothAdapter.getDefaultAdapter () . Say that use

to create, then call to get it.

Alternatively, you can call only the steady assistant.


Or you can see the build version and start mBluetoothAdapter , such as

  If (android.os.build.VERSION.SDK_INT & gt; = android.os.build.VERSION_CODES.JELLY_BEAN_MR2) {mBluetoothAdapter = bluetoothManager.getAdapter (); } And {mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter (); }    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -