0

I am trying to do a indoor location services using bluetooth LE scan to search for beacons. However, in order to display found bluetooth devices, location need to be turned on.

I tried searching online for solutions but to no avail. I have only enable the permission for the app not to turn on the location.

this is the code for the permission

if (this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("This app needs location access");
        builder.setMessage("Please grant location access so this app can detect peripherals.");
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);
            }
        });
        builder.show();
    }

i have also added the permission in android manifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Jure
  • 799
  • 6
  • 25
Loon
  • 75
  • 6
  • Have you already tried something like this? https://stackoverflow.com/questions/25175522/how-to-enable-location-access-programmatically-in-android -- do you plan to use gps or do you want to do it without it? – second Jul 10 '19 at 14:12
  • yes i have tried this. But variable 'statusCheck' is never used and i cannot resolve method 'buildAlertMessageNoGps(' – Loon Jul 11 '19 at 01:27
  • and i want to do it without gps i just need to turn on location services in order to display found bluetooth device – Loon Jul 11 '19 at 01:58
  • anyway thanks for your help! i somehow managed to do it already. – Loon Jul 11 '19 at 02:29

0 Answers0