| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 
 | public class BroadcastRechercheBluetooth extends BroadcastReceiver {
 
	protected Activity context;
	protected InteractionActivity UInterface;
	public ArrayList<BluetoothDevice> devicesBT;
	public ArrayList<String> nomDevicesBT;
 
	public BroadcastRechercheBluetooth(Activity context) {
		this.devicesBT = new ArrayList<BluetoothDevice>();
		this.nomDevicesBT = new ArrayList<String>();
		this.UInterface = new InteractionActivity(context);
	}
 
	public void onReceive(Context context, Intent intent) {
		String action = intent.getAction();
 
	   if(BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action))
	       UInterface.toast("Decouverte des peripherique en cours");
 
       if (BluetoothDevice.ACTION_FOUND.equals(action)) {
           BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
           this.devicesBT.add(device);
           this.nomDevicesBT.add(device.getName());
           UInterface.toast(device.getName()+" "+device.getAddress());
       }
       if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
           UInterface.toast("Decouverte des peripherique termine");
 
 
	}
 
	public ArrayList<BluetoothDevice> getListDevicesBT() {
		return devicesBT;
	}	
	public ArrayList<String> getListNomDevicesBT() {
		return nomDevicesBT;
	}	
} | 
Partager