I want to connect to this device: http://www.rhydolabz.com/index.php?main_page=product_info&products_id=479
I tried using the BluetoothChat
class from the samples. But it did not work. It says unable to connect device
.
Then I tried to use the following code within try catch
// Create a Socket connection: need the server's UUID number
Method m = d.getClass().getMethod("createRfcommSocketToServiceRecord", new Class[] { int.class });
socket = (BluetoothSocket) m.invoke(d, 1);
socket.connect();
Log.d("WCAM", ">>Client connectted");
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
socket.close();
Toast.makeText(this, "Bluetooth is Connected", Toast.LENGTH_LONG).show();
and I get the following error
04-18 20:45:01.660: W/System.err(6780): java.lang.NoSuchMethodException: createRfcommSocketToServiceRecord [int]
04-18 20:45:01.660: W/System.err(6780): at java.lang.Class.getConstructorOrMethod(Class.java:460)
04-18 20:45:01.660: W/System.err(6780): at java.lang.Class.getMethod(Class.java:915)
04-18 20:45:01.660: W/System.err(6780): at com.xpleria.wirelesscontroller.Login.onStart(Login.java:90)
04-18 20:45:01.660: W/System.err(6780): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
04-18 20:45:01.670: W/System.err(6780): at android.app.Activity.performStart(Activity.java:4475)
04-18 20:45:01.670: W/System.err(6780): at android.app.Activity.performRestart(Activity.java:4526)
04-18 20:45:01.670: W/System.err(6780): at android.app.Activity.performResume(Activity.java:4531)
04-18 20:45:01.670: W/System.err(6780): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
04-18 20:45:01.670: W/System.err(6780): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
04-18 20:45:01.670: W/System.err(6780): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1173)
04-18 20:45:01.670: W/System.err(6780): at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 20:45:01.680: W/System.err(6780): at android.os.Looper.loop(Looper.java:137)
04-18 20:45:01.680: W/System.err(6780): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-18 20:45:01.680: W/System.err(6780): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 20:45:01.680: W/System.err(6780): at java.lang.reflect.Method.invoke(Method.java:511)
04-18 20:45:01.680: W/System.err(6780): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
04-18 20:45:01.680: W/System.err(6780): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
04-18 20:45:01.680: W/System.err(6780): at dalvik.system.NativeStart.main(Native Method)
Any way how I can modify my code..?