Skip to content

Instantly share code, notes, and snippets.

@sidishere
Created December 24, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidishere/fefbeb8b5c902ec9af28efb2dce76b2c to your computer and use it in GitHub Desktop.
Save sidishere/fefbeb8b5c902ec9af28efb2dce76b2c to your computer and use it in GitHub Desktop.
private AdapterView.OnItemClickListener mDeviceClickListener= new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3)
{
// Cancel discovery because it's costly and we're about to connect
bluetoothAdapter.cancelDiscovery();
Toast.makeText(getApplicationContext(),"Stopping discovery",Toast.LENGTH_SHORT).show();
// Get the device MAC address, which is the last 17 chars in the View String
info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
// Create the result Intent and include the MAC address Intent
intent = new Intent(BluetoothActivity.this,LedControl.class);
intent.putExtra("DEVICE_ADDRESS", address);
// Set result and finish this Activity
startActivity(intent);
}
}
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment