Android Open Source - GlassToPhoneBluetooth Client Bluetooth Connection Thread






From Project

Back to project page GlassToPhoneBluetooth.

License

The source code is released under:

MIT License

If you think the Android project GlassToPhoneBluetooth listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ktlab.lib.connection.bluetooth;
//from   ww w.j  ava2  s .c  o m
import java.io.IOException;

import android.bluetooth.BluetoothDevice;
import android.os.Message;

public class ClientBluetoothConnectionThread extends BluetoothConnectionThread {

    protected final BluetoothDevice mDevice;

    public ClientBluetoothConnectionThread(BluetoothDevice device, Message msg) {
        super(msg);
        mDevice = device;
    }

    @Override
    protected void getSocket() {

        try {
            mSocket = mDevice.createRfcommSocketToServiceRecord(BluetoothConnection.SERVICE_UUID);
        } catch (IOException e) {
            mSocket = null;
            return;
        }

        int count = 0;
        do {
            try {
                if (mSocket != null) {
                    mSocket.connect();
                }
                break;
            } catch (IOException e) {
                // DO NOTHING
            }
            // retry
        } while (count++ < 5);
    }
}




Java Source Code List

com.space150.android.glass.camerazoom.DeviceSelectActivity.java
com.space150.android.glass.camerazoom.MainActivity.java
com.zlglassworks.glassbluetoothtest.DeviceSelectDialogFragment.java
com.zlglassworks.glassbluetoothtest.MainActivity.java
ktlab.lib.connection.CommandReceiveThread.java
ktlab.lib.connection.CommandReceiveThread.java
ktlab.lib.connection.CommandSendThread.java
ktlab.lib.connection.CommandSendThread.java
ktlab.lib.connection.ConnectionCallback.java
ktlab.lib.connection.ConnectionCallback.java
ktlab.lib.connection.ConnectionCommand.java
ktlab.lib.connection.ConnectionCommand.java
ktlab.lib.connection.ConnectionThread.java
ktlab.lib.connection.ConnectionThread.java
ktlab.lib.connection.Connection.java
ktlab.lib.connection.Connection.java
ktlab.lib.connection.bluetooth.BluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.BluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.BluetoothConnection.java
ktlab.lib.connection.bluetooth.BluetoothConnection.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnection.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnection.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnection.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnection.java