jump To Open Bluetooth - Android Bluetooth

Android examples for Bluetooth:Turn On bluetooth

Description

jump To Open Bluetooth

Demo Code


//package com.java2s;

import android.bluetooth.BluetoothAdapter;

import android.content.Context;
import android.content.Intent;

public class Main {

    public static void jumpToOpenBluetooth(Context context) {
        if (isThisMahionSupportBluetooth() && !isBluetoothHadOpen()) {
            Intent intent = new Intent(
                    BluetoothAdapter.ACTION_REQUEST_ENABLE);
            context.startActivity(intent);
        }//from  ww w.j  a v a2s  .  c o  m
    }

    public static boolean isThisMahionSupportBluetooth() {
        BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
        if (null != ba) {
            return true;
        }
        return false;
    }

    public static boolean isBluetoothHadOpen() {
        if (isThisMahionSupportBluetooth()) {
            BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
            if (ba.isEnabled()) {
                return true;
            }
        }
        return false;
    }
}

Related Tutorials