Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Android 10 - ACTIVITY_RECOGNITION #60

Closed
Feduch opened this issue Aug 5, 2020 · 5 comments
Closed

Android 10 - ACTIVITY_RECOGNITION #60

Feduch opened this issue Aug 5, 2020 · 5 comments

Comments

@Feduch
Copy link

Feduch commented Aug 5, 2020

Hi!

On Android 10 getting PlatformException

I/flutter (11492): PlatformException(FitKit, 10: SecurityException: com.google.step_count.delta requires android.permission.ACTIVITY_RECOGNITION, null) I/flutter (11492): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569) I/flutter (11492): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156) I/flutter (11492): <asynchronous suspension> I/flutter (11492): #2 MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:342) I/flutter (11492): <asynchronous suspension> I/flutter (11492): #3 FitKit.read.<anonymous closure> (package:fit_kit/src/fit_kit.dart:0) I/flutter (11492): <asynchronous suspension>

How to fix it?

@LaxmikanthMadhyastha
Copy link

LaxmikanthMadhyastha commented Aug 12, 2020

I am also facing this issue after changing the targetSdkVersion and compileSdkVersion to 29 and I think this is something to do with new privacy changes in the new Android 10. More info on the below link.

https://developer.android.com/about/versions/10/privacy/changes#physical-activity-recognition

I was able to solve this by manually asking the permission for ACTIVITY_RECOGNITION using permission handler package and also added below line to AndroidManifest.xml file

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

Is there any way the fitkit package can handle this?

@Feduch
Copy link
Author

Feduch commented Aug 12, 2020

Hi!

I using this package, for manually asking the permission.

https://pub.dev/packages/permission_handler

@Feduch
Copy link
Author

Feduch commented Sep 21, 2020

Hi!

Code how you can request access to activity on 10 android.

    if (Platform.isAndroid) {
      var androidInfo = await DeviceInfoPlugin().androidInfo;
      int sdkInt = androidInfo.version.sdkInt;

      if (sdkInt > 28) {
        bool activityRecognitionStatus =
            await Permission.activityRecognition.status.isGranted;

        if (!activityRecognitionStatus) {
          if (await Permission.activityRecognition.request().isGranted) {}
        }
      }
    }
  }`

@Feduch Feduch closed this as completed Sep 21, 2020
@cubuspl42
Copy link

@Feduch I think that it's really not obvious that this snippet is required for FitKit to work on Android phones! Why isn't this logic part of FitKit.requestPermissions or another helper method, let's say FitKit.requestSystemPermissions?

At very least it should be explicitly documented in the README that such snippet is required, or even included in the example code!

@krokyze
Copy link
Owner

krokyze commented Dec 4, 2020

@Feduch @cubuspl42 you're always welcome to make a PR with changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants