/** * Execute {@link #connect()} asynchronously by creating a new thread and * calling {@code connect()} in the thread. If {@code connect()} failed, * {@link WebSocketListener#onConnectError(WebSocket, WebSocketException) * onConnectError()} method of {@link WebSocketListener} is called. * * @return * {@code this} object. * * @since 1.8 */ public WebSocket connectAsynchronously() { Thread thread = new ConnectThread(this); // Get the reference (just in case) ListenerManager lm = mListenerManager; if (lm != null) { lm.callOnThreadCreated(ThreadType.CONNECT_THREAD, thread); } thread.start(); return this; }
@Override public void runMain() { try { mWebSocket.connect(); } catch (WebSocketException e) { handleError(e); } }
connectThread = new ConnectThread(); connectThread.start();
public void onItemClickListener(AdapterView<?> arg0, View arg1,int arg2, long arg3 ){ if (mBluetoothAdapter.isDiscovering()){ mBluetoothAdapter.cancelDiscovery(); } if (mArrayAdapter.getItem(arg2).contains("NOMBRE_ESTEF_DEVICE")){ BluetoothDevice selectedDevice = devices.get(arg2); Toast.makeText(getApplicationContext(), "Device is paired", duration ).show(); ConnectThread connect = new ConnectThread(selectedDevice); connect.start(); } }
ConnectThread ct = new ConnectThread(device); ct.start();
/** * try catch becuase of SupportLibrary bug link "https://code.google.com/p/android/issues/detail?id=220762" * * @param v */ public void showConnectionErr(View v) { try { Snackbar b = getFailureSnackBar(v, "Bluetooth connection lost", false); b.setAction("RETRY", new View.OnClickListener() { @Override public void onClick(View v) { new ConnectThread().execute(); } }); b.show(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mBluetoothAdapter.isDiscovering()){ mBluetoothAdapter.cancelDiscovery(); } if (mArrayAdapter.getItem(arg2).contains("NOMBRE_ESTEF_DEVICE")){ BluetoothDevice selectedDevice = devices.get(arg2); Toast.makeText(getApplicationContext(), "Device is paired", duration ).show(); ConnectThread connect = new ConnectThread(selectedDevice); connect.start(); } }
@Override public void runMain() { try { mWebSocket.connect(); } catch (WebSocketException e) { handleError(e); } }
/** * Execute {@link #connect()} asynchronously by creating a new thread and * calling {@code connect()} in the thread. If {@code connect()} failed, * {@link WebSocketListener#onConnectError(WebSocket, WebSocketException) * onConnectError()} method of {@link WebSocketListener} is called. * * @return * {@code this} object. * * @since 1.8 */ public WebSocket connectAsynchronously() { Thread thread = new ConnectThread(this); // Get the reference (just in case) ListenerManager lm = mListenerManager; if (lm != null) { lm.callOnThreadCreated(ThreadType.CONNECT_THREAD, thread); } thread.start(); return this; }