get Phone Bluetooth State - Android Phone

Android examples for Phone:Bluetooth

Description

get Phone Bluetooth State

Demo Code


//package com.java2s;

import android.bluetooth.BluetoothAdapter;

public class Main {

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

Related Tutorials