Android 10 permissions

Hi,
I have developed an App for both Android and Apple.
Typically the Apps scan and list the sensors without any problem.
My latest customer has a Samsung S9+ running Android 10 or 11. This has a number of changes re permissions.
The MetaBase App on the phone can see and connect to the sensor.
However my Android App cannot see the sensor when it does its normal scan.
Are there any on-phone settings I can change to fix the problem or do I need to change the permission setting in the Android manifest ? If so, what are they ?
Your help would be really appreciated.
Best regards,
Steve

Comments

  • Hi,
    I have found a fix for the problem. This was very helpful

    https://github.com/Polidea/react-native-ble-plx/issues/730  
    

    I changed my build.gradle (:app) compile and target versions from 29 to 28 and the App could then find the sensors.

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.x.x"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 31
        versionName "2.1.31"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    

    Hope this helps anyone else.
    Best regards,
    Steve

  • Hi Again,

    While changing the target API level to 28, it then runs into a problem when uploading it to the Google Play store.

    It looks like I still need help to sort this out !!

  • Has anyone found a solution to this problem? I am running into the same issue.

    Thanks.

  • I am almost done and ready to release the new Android lib. It has new sdk targets, could help (not 100% sure though).

  • Do you think it will be today or later this week? I will test it as soon as you release it and let you know.
    Thanks.
    Jeff

  • I just released 3.8.0 for you to try out

    allprojects {
        repositories {
            jcenter()
            google()
            ivy {
                url "https://mbientlab.com/releases/ivyrep"
                layout "gradle"
            }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    ext {
        // copied global configuration from parse ui repo
        // https://github.com/ParsePlatform/ParseUI-Android/blob/master/build.gradle
        compileSdkVersion = 30
        buildToolsVersion = "29.0.2"
        supportLibVersion = "28.0.0"
        metawearSdk = 'com.mbientlab:metawear:3.8.0'
    }
    
  • Laura,
    When I change the compiledSDKVersion to 29 or 30 and the corresponding buildTooolsVersion my app no longer see any of the Metawear sensors.
    Thanks.

  • But it works at 29?

  • edited April 2021

    I tested and it worked for me on 29 and 30.
    Also I updated the scanner lib:

    dependencies {
          implementation 'com.mbientlab.bletoolbox:scanner:0.3.0'
    }
    
  • edited April 2021

    Laura,
    No, it still does not work.
    Thank you,
    Jeff

  • Laura,
    It only works when the targetSdkVersion is 28. Once I got to 29 or 30 I cannot find any of the sensors.
    Jeff

  • edited April 2021

    Laura,
    In order to see any sensors once migrating to SDK 29 or 30 you need to check for:

    BleScannerFragment only looks for ACCESS_COARSE_LOCATION. I made a local copy of bletoolbox and modified the BleScannerFragment to:

    private boolean checkLocationPermission() {
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
                   getActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.title_request_permission);
                builder.setMessage(R.string.error_location_access);
                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);
                        requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);
                    }
                });
                builder.show();
                return false;
            }
     else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
                    getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.title_request_permission);
                builder.setMessage(R.string.error_location_access);
                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);
                        requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_FINE_LOCATION);
                    }
                });
                builder.show();
                return false;
            }
            return true;
        }
    
  • edited April 2021

    Odd. My stuff was working for 29. I haven't tested 30 yet. Did you use my latest bletoolbox version? I released 0.3.0 yesterday. I can release 0.3.1 with the changes you mentioned if you want.

  • I tried for 29 and it did not work and yes I did use bletookbox 0.3.0. I am wondering if your app is checking the ACCESS_FINE_LOCATION somewhere else.
    You may want to clean up my code as I was hard coding it to see if I could get it to work.

    Jeff

  • Maybe Android manifest is different? I will release 0.3.1

  • I reverted back to the bletoolbox 0.3.0 and got it to work now. I just had to make sure that the permission for ACCESS_FINE_LOCATION exists for 29 and above.

  • I think I should still release 0.3.1 with ACCESS_FINE_LOCATION, what do you think?

  • Or just update the setup instructions to include the permissions in the AndroidManifest file as well as checking for it during the start of the app.

  • I published 0.3.1, you want to try it out?

  • I will try it and let you know.
    Jeff

  • Yes, I just verified that 0.3.1 works great.
    Jeff

  • Awesome, thanks Jeff. I'm going to work on release 8.3.1 android sdk. I will let you know what that's ready. You can mess around with 8.3.0 but it's not complete.

Sign In or Register to comment.