예제 #1
0
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position);
   if (device == null) return;
   final Intent intent = new Intent(this, DeviceControlActivity.class);
   intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_NAME, device.getName());
   intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_ADDRESS, device.getAddress());
   if (mScanning) {
     mBluetoothAdapter.stopLeScan(mLeScanCallback);
     mScanning = false;
   }
   startActivity(intent);
 }
예제 #2
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_scan:
       mLeDeviceListAdapter.clear();
       scanLeDevice(true);
       break;
     case R.id.menu_stop:
       scanLeDevice(false);
       break;
   }
   return true;
 }
예제 #3
0
 @Override
 protected void onPause() {
   super.onPause();
   scanLeDevice(false);
   mLeDeviceListAdapter.clear();
 }