is Device Can Advertise via Bluetooth - Android Bluetooth

Android examples for Bluetooth:Bluetooth Device

Description

is Device Can Advertise via Bluetooth

Demo Code


//package com.java2s;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

public class Main {
    public static boolean isDeviceCanAdvertise(Context context) {
        BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (context.getApplicationContext().getPackageManager()
                    .hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
                try {
                    return mAdapter.getBluetoothLeAdvertiser() != null;
                } catch (Exception e) {
                    return false;
                }/*from  www.  j  av  a 2  s.co  m*/
            }
        }
        return false;
    }
}

Related Tutorials