0

I have a List View, with a list of available blue tooth devices, and on selecting an item, i want to connect gatt on that device. But the compiler says "The method connectGatt(Context, boolean, BluetoothGattCallback) in the type BluetoothDevice is not applicable for the arguments (new AdapterView.OnItemClickListener(){}, boolean, BluetoothGattCallback)"

Here is my code:

  ListView deviceListView = (ListView)findViewById(R.id.new_devices);

  deviceListView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterview, View rowView, int position, long id) {


                WL.getInstance().sendActionToJS("LoadPageReceiver");                    

                BluetoothDevice device =  (BluetoothDevice)((mDevices.toArray())[position]);
                Log.i(TAG, "Connecting to: " + device.getName());


                //make connection
                mConnectedGATT = device.connectGatt(this, true, mGattCallback);
                //display progress UI   
                mHandler.sendMessage(Message.obtain(null, MSG_PROGRESS, "Connecting to " + device.getName() + "..."));

            }}
        );
Samra
  • 1,815
  • 4
  • 35
  • 71

0 Answers0