title: How to make a bluetooth connection in android?
body: <p>I want to connect to this device: <a href="http://www.rhydolabz.com/index.php?main_page=product_info&amp;products_id=479" rel="nofollow">http://www.rhydolabz.com/index.php?main_page=product_info&amp;products_id=479</a></p>
  
  <p>I tried using the <code>BluetoothChat</code> class from the samples. But it did not work. It says <code>unable to connect device</code>.</p>
  
  <p>Then I tried to use the following code within try catch</p>
  
  <pre><code>        // 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", "&gt;&gt;Client connectted");
  inputStream = socket.getInputStream();
  outputStream = socket.getOutputStream();
  socket.close();
  Toast.makeText(this, "Bluetooth is Connected", Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>and I get the following error</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Any way how I can modify my code..?</p>