make Bluetooth device Discoverable - Android Bluetooth

Android examples for Bluetooth:Bluetooth Device

Description

make Bluetooth device Discoverable

Demo Code


//package com.java2s;

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

import android.content.Intent;

import android.util.Log;

public class Main {
    public static void makeDiscoverable(Activity activity, int duration) {
        Intent discoverableIntent = new Intent(
                BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(//from   w  w  w  .j  av a 2  s. c  o  m
                BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, duration);
        activity.startActivity(discoverableIntent);
        Log.i("BluetoothUtils", "Discoverable ");
    }
}

Related Tutorials