Hello, I am using Android 2.1 sdk with Motorolad Droid A855 model, when try to connect to Bluetooth (Socket SPP ), I am getting the following error as per logcat, and getting exception throw in socket.conect();
09-07 05:03:40.874: ERROR/BluetoothEventLoop.cpp(1102): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1142/hci0/dev_00_0E_6D_BA_89_F3
09-07 05:03:41.217: DEBUG/BluetoothService(1102): updateDeviceServiceChannelCache(00:0E:6D:BA:89:F3)
09-07 05:03:41.233: DEBUG/BluetoothService(1102): Cleaning up failed UUID channel lookup: 00:0E:6D:BA:89:F3 550e8400-e29b-41d4-a716-446655440000
09-07 05:03:41.241: INFO/BTconnect(1650): Step 7
09-07 05:03:41.241: ERROR/--------Inner Exception-----(1650): Socket not conncected
09-07 05:03:41.256: VERBOSE/BluetoothEventRedirector(1660): Received android.bleutooth.device.action.UUID
09-07 05:03:41.327: INFO/ActivityManager(1102): Displayed activity com.sample.BT/.BluetoothDemo: 947 ms (total 947 ms)
09-07 05:03:45.038: ERROR/BluetoothEventLoop.cpp(1102): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1142/hci0/dev_00_0E_6D_BA_89_F3
09-07 05:03:46.499: VERBOSE/BluetoothEventRedirector(1660): Received android.bleutooth.device.action.UUID
and here is my code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
out = (TextView) findViewById(R.id.out);
// Getting the Bluetooth adapter
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
out.append("\nAdapter: " + mBluetoothAdapter);
UUID uuid = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
if(mBluetoothAdapter==null) {
out.append("\nBluetooth NOT supported. Aborting.");
return;
}
Log.i("BTDemo", ": "+ mBluetoothAdapter.isEnabled());
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
else
{
out.append("\nBluetooth Adapter Enabled");
}
try {
BluetoothDevice devices=mBluetoothAdapter.getRemoteDevice("00:0E:6D:BA:89:F3");
if(devices!=null)
{
socket = devices.createRfcommSocketToServiceRecord(uuid);
Log.i("In Socket","Socket"+socket);
Log.i("BTconnect", "Step 4");
}
else
{
Log.e("BTConnect","Bluetooth device is null");
return ;
}
Log.i("BTconnect", "Step 5");
// Listing paired devices
out.append("\nDevices Pared:");
//BluetoothDevice devices;
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
for (BluetoothDevice device: pairedDevices)
{
out.append("\nFound device: " + device);
}
} catch (Exception e) {
e.printStackTrace();
}
try{
if(socket !=null) // checking for socket is created or not
{
socket.connect();
Log.i("BTconnect", "Step 6");
Log.i("BTconnect", "Socket Connected");
out.append("\n Socket Connected");
}
else
{
out.append("\n\n Socket is Null");
}
}catch(Exception e)
{
Log.i("BTconnect", "Step 7");
Log.e("--------Inner Exception-----", "Socket not conncected");
out.append("\n\n\n --------Inner Exception----- Socket not conncected");
try {
socket.close();
out.append("\n\n Socket closed");
} catch (IOException closeException)
{
Log.e("InitBluetoothDevice","while closing socket in catch block of connect()"+closeException.getMessage());
out.append("\n\n --------Exception----- while closing socket");
}
}
}
and the manifest file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.BT"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".BluetoothDemo"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
</manifest>
I tried to connect using different UUID's but no success
Can some body help in connecting to bluetooth,
Thanks in advance Chiranjeevi.