Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;

import android.content.Intent;

public class Main {
    /**
     * Enable the bluetooth adapter.
     */
    public static void bluetoothEnable(Activity activity, boolean discoverable, int reqCode) {
        if (discoverable) {
            Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
            discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
            activity.startActivityForResult(discoverableIntent, reqCode);
        } else {
            Intent bluetoothIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            activity.startActivityForResult(bluetoothIntent, reqCode);
        }
    }
}