Note that there are some explanatory texts on larger screens.

plurals
  1. POBluetooth works one way only
    primarykey
    data
    text
    <p>I am very new to android and java so be gentle :) I'm trying to connect two phones via bloototh. i am making both phones to listen of incoming calls by creating serversocket, then initializing connection from one phone (as a client). funny part is that when I try to make my LG (android version 2.3.4) to connect HTC (android 2.2.1) everything works fine, but when i try to make HTc phone to connect as a client i get no result. Debugger shows that HTC fails at mmSocket.connect(); and executes catch (IOException connectException). My code is basicly copy/paste from android bluetooth tutorial. Any suggestions why phones behaves differently? Connect thread: </p> <pre><code> private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) { // Use a temporary object that is later assigned to mmSocket, // because mmSocket is final BluetoothSocket tmp = null; mmDevice = device; // Get a BluetoothSocket to connect with the given BluetoothDevice try { // MY_UUID is the app's UUID string, also used by the server code tmp = device.createRfcommSocketToServiceRecord(MY_UUID); } catch (IOException e) { } mmSocket = tmp; } public void run() { // Cancel discovery because it will slow down the connection BtAdapter.cancelDiscovery(); try { // Connect the device through the socket. This will block // until it succeeds or throws an exception mmSocket.connect(); **HTC phones fails here and goes to CATCH block** // make info message Message msg = mainHandler.obtainMessage(); Bundle bundle = new Bundle(); String btnTxt = "Connected"; bundle.putString("myKey", btnTxt); msg.setData(bundle); mainHandler.sendMessage(msg); } catch (IOException connectException) { // Unable to connect; close the socket and get out try { mmSocket.close(); } catch (IOException closeException) { } return; } // Do work to manage the connection (in a separate thread) ConnectedThread conThread = new ConnectedThread(mmSocket); conThread.start(); } /** Will cancel an in-progress connection, and close the socket */ public void cancel() { try { mmSocket.close(); } catch (IOException e) { } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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