I am writing a program which needs to be run in Android 2.0. I am currently trying to connect my android device to an embedded bluetooth chip. I have been given information as t
I also faced the same issue and this is how I solved it for Android 2.3.3. I think the same solution will work for android 2.2 also.
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@SuppressLint("NewApi")
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Toast.makeText(getApplicationContext(),"Device: "+device.getName(),Toast.LENGTH_SHORT).show();
devices.add(device.getName() + "\n" + device.getAddress());
list.add(device);
}
else if(BluetoothDevice.ACTION_UUID.equals(action)){
Toast.makeText(getApplicationContext(),"I am Here",Toast.LENGTH_SHORT).show();
}
else {
if(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
Toast.makeText(getApplicationContext(),"Done Scanning..",Toast.LENGTH_SHORT).show();
Iterator itr = list.iterator();
while(itr.hasNext())
{
BluetoothDevice dev=itr.next();
if(dev.fetchUuidsWithSdp())
{
Parcelable a[]=dev.getUuids();
Toast.makeText(getApplicationContext(),dev.getName()+":"+a[0],Toast.LENGTH_SHORT).show();
}
}
}
}
}
};