get Bluetooth State - Android Bluetooth

Android examples for Bluetooth:Bluetooth State

Description

get Bluetooth State

Demo Code


//package com.java2s;

import android.bluetooth.BluetoothAdapter;

public class Main {

    public static int getBluetoothState() throws Exception {
        BluetoothAdapter bluetoothAdapter = BluetoothAdapter
                .getDefaultAdapter();/*from  w ww .  j  a  va  2 s .c  o m*/
        if (bluetoothAdapter == null) {
            throw new Exception("bluetooth device not found!");
        } else {
            return bluetoothAdapter.getState();
        }
    }
}

Related Tutorials