public static enum SystemRequirementsChecker.Requirement extends java.lang.Enum<SystemRequirementsChecker.Requirement>
| Enum Constant and Description |
|---|
BLUETOOTH_DISABLED
Invoked when Bluetooth is not enabled on the device.
|
LOCATION_DISABLED
Invoked when Location Services are enabled and required for Bluetooth LE scanning.
|
LOCATION_PERMISSION
Invoked when:
If running on Android M or later and your app is targeting SDK < 23 (M),
any location permission (ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION)
must be granted for background beacon detection.
If running on Android M or later and your app is targeting SDK >= 23 (M),
any location permission (ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION)
must be granted.
|
| Modifier and Type | Method and Description |
|---|---|
static SystemRequirementsChecker.Requirement |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static SystemRequirementsChecker.Requirement[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SystemRequirementsChecker.Requirement LOCATION_PERMISSION
Example code for asking for runtime permission:
private void checkLocationPermissions() {
if (SystemRequirementsHelper.shouldShowCoarseLocationRequestPermissionRationale(this)) {
buildPermissionRationaleDialog(new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialog, int which) {
requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_LOCATION_PERMISSION);
}
}).show();
} else {
requestPermissions(new String[] {Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_LOCATION_PERMISSION);
}
}
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == REQUEST_LOCATION_PERMISSION) {
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startScanning();
} else {
Toast.makeText(getApplicationContext(), R.string.error_no_location_permission, Toast.LENGTH_LONG).show();
}
}
}
private AlertDialog.Builder buildPermissionRationaleDialog(DialogInterface.OnClickListener listener) {
return new AlertDialog.Builder(this)
.setTitle(R.string.requesting_location_permission)
.setMessage(R.string.requesting_location_access_rationale)
.setPositiveButton(android.R.string.ok, listener)
.setCancelable(true);
public static final SystemRequirementsChecker.Requirement LOCATION_DISABLED
You should ask user to enable it:
// It is recommended to show dialog with explanation. // Dialog title: Requesting location access // Dialog message: Detecting beacons requires Location to be enabled.We'll never access your GPS location without your knowledge. // OK button: Go to settings to enable // Cancel button: I don't want to do this now Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); activity.startActivity(intent);
public static final SystemRequirementsChecker.Requirement BLUETOOTH_DISABLED
You should ask user to enable it via:
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
public static SystemRequirementsChecker.Requirement[] values()
for (SystemRequirementsChecker.Requirement c : SystemRequirementsChecker.Requirement.values()) System.out.println(c);
public static SystemRequirementsChecker.Requirement valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is null