Hi: I'm developing an application which does scans for nearby
bluetooth devices which are in discoverable mode. On the Google Nexus
One device, the device scanning is working perfectly. But on the HTC
Desire, "ACTION_DISCOVERY_FINISHED" is called once and does not call
the action "BluetoothDevice.ACTION_FOUND". Any other attempts to start
another scan by calling "startDiscovery()" on BluetoothAdapter class
are ignored. Under some circumstances it works on the HTC Desire for a
few (around 10) bluetooth scanning attempts.
Has HTC introduced a bug on their custom firmware?
The simplest class demonstrating the issue is as follows:
===================================================
public class BluetoothTest extends Activity {
private BluetoothAdapter mBtAdapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
IntentFilter filter = new
IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
IntentFilter filter2 = new
IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter2);
mBtAdapter.startDiscovery();
}
private final BroadcastReceiver mReceiver = new
BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
Log.d("DEBUG", "BT Device found");
}
else if
(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
Log.d("DEBUG","Entered ACTION_DISCOVERY_FINISHED ");
mBtAdapter.startDiscovery();
}
}
};
}
======================================
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en