Note that there are some explanatory texts on larger screens.

plurals
  1. POUnsecured Bluetooth connection in Android
    primarykey
    data
    text
    <p>I have been challenged by a professor to develop a little Bluetooth Demo app on Android. I knew nothing about developping for Android until 2 weeks ago when he gave me that challenge. I'm also quite new at Java programming in general, so I'm starting from far. But anyway...</p> <p>So I did most of the tutorial, and I read about Bluetooth in Android, looked at the Bluetooth Chat sample code, and I'm now trying to do my little app. So for my demo, I will try to establish a connection between my real phone and my Bluetooth mouse. I want to move a shape on the screen of my phone in response to my mouse movement. </p> <p>I encounter many problem, but so far my main one is to open a socket with my unsecure mouse. When I try using the method <code>listenUsingRfcommWithServiceRecord</code>, it ask a UUID as a parameter. But my mouse most likely doesn't have a UUID to respond, so I guess this method is not the good one.</p> <p>When I read the documentation about this method, it says that to open an unsecure server socket with a device like a mouse, I must use the <code>listenUsingInsecureRfcommWithServiceRecord</code> method. But this method is not available when I call it, it gets underlined in red and Eclipse says that it is undefined for the type BluetoothAdapter.</p> <pre><code>private BluetoothServerSocket connectDevice(BluetoothAdapter adapter, BluetoothDevice device){ BluetoothServerSocket socket = null; try{ socket = adapter.listenUsingInsecureRfcommWithServiceRecord(device.getName(), UUID.randomUUID()); } catch(IOException e){ Toast.makeText(this, "Connection failed.\n" + e.getMessage(), Toast.LENGTH_SHORT); } return socket; } </code></pre> <p> Please don't flame me if I'm doing it all wrong, it's my first question here and I'm starting with Java programming.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload