is Devise Can Advertise - Android android.bluetooth

Android examples for android.bluetooth:Bluetooth

Description

is Devise Can Advertise

Demo Code

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

public class Main{

    public static boolean isDeviseCanAdvertise(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;
                }//www .  ja va  2  s . com
            }
        }
        return false;
    }

}

Related Tutorials