1. private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
    2.  
    3.         @Override
    4.         public void onReceive(Context context, Intent intent) {
    5.             String action = intent.getAction();
    6. ArrayList<HashMap<String, String> arl = new ArrayList<HashMap<String, String>();    
    7.             // When discovery finds a device
    8.             if (BluetoothDevice.ACTION_FOUND.equals(action)) {
    9.                 // Get the BluetoothDevice object from the Intent
    10.                 BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    11.                 // If it's already paired, skip it, because it's been listed already
    12.                 HashMap<String, String> deviceMap = new HashMap<String, String>();
    13.                 deviceMap.put(device.getName(), device.getAddress());
    14.                 arl.add(deviceMap);
    15.  
    16.             // When discovery is finished, change the Activity title
    17.             } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
    18.                 setProgressBarIndeterminateVisibility(false);
    19.                 setTitle(R.string.select_device);
    20.                 if (mNewDevicesArrayAdapter.getCount() == 0) {
    21.                     String noDevices = getResources().getText(R.string.none_found).toString();
    22.                     mNewDevicesArrayAdapter.add(noDevices);
    23.                 }
    24.             }
    25.         }
    26.  
    27.  
    28.     };

 

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()