Get Bluetooth connection State To String - Android Bluetooth

Android examples for Bluetooth:Bluetooth State

Description

Get Bluetooth connection State To String

Demo Code


//package com.java2s;

import android.bluetooth.BluetoothProfile;

public class Main {
    public static String connectionStateToString(int state) {
        switch (state) {
        case BluetoothProfile.STATE_CONNECTED:
            return "STATE_CONNECTED";
        case BluetoothProfile.STATE_DISCONNECTED:
            return "STATE_DISCONNECTED";
        case BluetoothProfile.STATE_CONNECTING:
            return "STATE_CONNECTING";
        case BluetoothProfile.STATE_DISCONNECTING:
            return "STATE_DISCONNECTING";
        default://from   w w  w.j  ava  2  s  .  c o  m
            return "unknown state:" + state;
        }
    }
}

Related Tutorials