src/com/btwiz/test/Tester.java
public static void discoverNearbyDevices(final Context context) {		
		try {
			if (!BTWiz.isEnabled(context)) {
				// TODO call startActivity with BTWiz.enableBTIntent() allowing user to enable BT
				return; 
			}
		} catch (DeviceNotSupportBluetooth e) {
			// TODO disable BT functionality in your app
			return; 
		}
		
		
		final MarkCompletionListener completeListener = new MarkCompletionListener(); 
		final GetAllDevicesListener deviceDiscoveredListener = new GetAllDevicesListener(); 
		
		boolean started = BTWiz.startDiscoveryAsync(context, completeListener, deviceDiscoveredListener);				
		if (!started) {
			// TODO handle discovery error
			return; 
		}
		

		
		// start a thread that will block until discovery has completed. 
		// note: this is for demonstration only. standard apps should typically 
		// create a IDeviceLookupListener implementation class to handle each new discovered
		// device as it arrives and not block a thread until discovery completion   
		new Thread() {
			public void run() {
				completeListener.blockUntilCompletion(); 				
				// and iterate results
				ArrayList<BluetoothDevice> allDiscoveredDevices = deviceDiscoveredListener.getAll(); 
				for (BluetoothDevice device: allDiscoveredDevices) {
					String name = device.getName();
					String addr = device.getAddress();
					int major = device.getBluetoothClass().getMajorDeviceClass();
					String majorStr = Utils.majorToString(major);
					Log.d("Tester", "Discovered device: " + name + ", " + addr + ", " + majorStr); 
				}
				
				BTWiz.cleanup(context); // cleanup BT resources
				
			};
		}.start();	 	
	}
/**
	 * Run discovery and returns a list of all discovered devices
	 */
Run discovery and returns a list of all discovered devices
Run discovery and returns a list of all discovered devices
public static void discoverNearbyDevices(final Context context) {		
		try {
			if (!BTWiz.isEnabled(context)) {
				return; 
			}
		} catch (DeviceNotSupportBluetooth e) {
			return; 
		}
		final MarkCompletionListener completeListener = new MarkCompletionListener(); 
		final GetAllDevicesListener deviceDiscoveredListener = new GetAllDevicesListener(); 
		boolean started = BTWiz.startDiscoveryAsync(context, completeListener, deviceDiscoveredListener);				
		if (!started) {
			return; 
		}
		new Thread() {
			public void run() {
				completeListener.blockUntilCompletion(); 				
				ArrayList<BluetoothDevice> allDiscoveredDevices = deviceDiscoveredListener.getAll(); 
				for (BluetoothDevice device: allDiscoveredDevices) {
					String name = device.getName();
					String addr = device.getAddress();
					int major = device.getBluetoothClass().getMajorDeviceClass();
					String majorStr = Utils.majorToString(major);
					Log.d("Tester", "Discovered device: " + name + ", " + addr + ", " + majorStr); 
				}
				BTWiz.cleanup(context); 
			};
		}.start();	 	
	}
public static void discoverNearbyDevices ( final Context context ) { try { if ( ! BTWiz . isEnabled ( context ) ) { return ; } } catch ( DeviceNotSupportBluetooth e ) { return ; } final MarkCompletionListener completeListener = new MarkCompletionListener ( ) ; final GetAllDevicesListener deviceDiscoveredListener = new GetAllDevicesListener ( ) ; boolean started = BTWiz . startDiscoveryAsync ( context , completeListener , deviceDiscoveredListener ) ; if ( ! started ) { return ; } new Thread ( ) { public void run ( ) { completeListener . blockUntilCompletion ( ) ; ArrayList < BluetoothDevice > allDiscoveredDevices = deviceDiscoveredListener . getAll ( ) ; for ( BluetoothDevice device : allDiscoveredDevices ) { String name = device . getName ( ) ; String addr = device . getAddress ( ) ; int major = device . getBluetoothClass ( ) . getMajorDeviceClass ( ) ; String majorStr = Utils . majorToString ( major ) ; Log . d ( "Tester" , "Discovered device: " + name + ", " + addr + ", " + majorStr ) ; } BTWiz . cleanup ( context ) ; } ; } . start ( ) ; }
Run discovery and returns a list of all discovered devices
Run discovery and returns a list of all discovered devices
// TODO call startActivity with BTWiz.enableBTIntent() allowing user to enable BT // TODO disable BT functionality in your app // TODO handle discovery error // start a thread that will block until discovery has completed.  // note: this is for demonstration only. standard apps should typically  // create a IDeviceLookupListener implementation class to handle each new discovered // device as it arrives and not block a thread until discovery completion    // and iterate results // cleanup BT resources