Page 1014 - 3-2
P. 1014

public void scanDevice() {
                    Log.d(TAG, "Scan Device");


                    Intent serverIntent = new Intent(mActivity, DeviceListActivity.class);
                    mActivity.startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
                }


                public void getDeviceInfo(Intent data) {
                    //Get the device MAC address
                    String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
                    //Get the BluetoothDevice object
                    BluetoothDevice device = btAdapter.getRemoteDevice(address);


                    Log.d(TAG, "Get Device Info \n" + "address : " + address);


                    connect(device);
                }


                private class ConnectThread extends Thread {
                    public final BluetoothSocket mmSocket;
                    public final BluetoothDevice mmDevice;


                    public ConnectThread(BluetoothDevice device) {
                        mmDevice = device;
                        BluetoothSocket tmp = null;


                        try {
                            tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
                        } catch (IOException e) {
                            Log.e(TAG, "create() failed", e);
                        }
                        mmSocket = tmp;
                    }


                    public void run() {
                        Log.i(TAG, "BEGIN mConnectThread");
                        setName("ConnectThread");


                        btAdapter.cancelDiscovery();


                        try {
                            mmSocket.connect();
                            Log.d(TAG, "Connect Success");




                                                        - 1014 -
   1009   1010   1011   1012   1013   1014   1015   1016   1017   1018   1019