request to Enable Bluetooth - Android Bluetooth

Android examples for Bluetooth:Turn On bluetooth

Description

request to Enable Bluetooth

Demo Code


//package com.java2s;
import static android.bluetooth.BluetoothAdapter.*;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;

public class Main {
    private static final BluetoothAdapter ADAPTER = getDefaultAdapter();

    public static boolean requestEnable(Activity requester, int requestCode) {
        if (ADAPTER == null) {
            return false;
        }/*  w w w .j ava2s.c om*/

        final Intent i = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        requester.startActivityForResult(i, requestCode);
        return true;
    }
}

Related Tutorials