Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Health 10.2.0] Can not access health connect by only AppStore released app in Android version below 13 #958

Open
takashi11171117 opened this issue May 8, 2024 · 3 comments
Labels
bugfix a bug fix

Comments

@takashi11171117
Copy link

takashi11171117 commented May 8, 2024

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

  • Device: various
  • OS: Android below 13

Describe the bug

I am using the package for only getting step count in my flutter app.
When I called requestAuthorization method of health package somewhere with useHealthConnectIfAvailable,
I got this error by only PlayStore released app in Android version below 13.
(My app can run it by PlayStore released app in Android14 and local release builded app in Android below 13 )
This app can't access Health Connect like the link

The Link wrote
Apps currently need to be allowlisted to get access to Health Connect. You can follow the process outlined at: https://developer.android.com/guide/health-and-fitness/health-connect/frequently-asked-questions#q_how_do_i_request_access_to_readwrite_data_types

But I have approved the allowlist.

To Reproduce

Steps to reproduce the behavior -
Write code according to the10.2.0 of health package and release PlayStore.
Then call requestAuthorization method of health package somewhere.

  • AndroidManifest.xml (Only about health connect)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="hogehoge">
    <queries>
        <package android:name="com.google.android.apps.healthdata" />
        <intent>
            <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
        </intent>
    </queries>

    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
    <uses-permission android:name="android.permission.health.READ_STEPS"/>
    
    <application
        android:label="hage"
        android:name="hoge"
        android:icon="@mipmap/ic_launcher"
        requestLegacyExternalStorage="true"
        android:allowBackup="false">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
          android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
            </intent-filter>
        </activity>
        <activity-alias
            android:name="ViewPermissionUsageActivity"
            android:exported="true"
            android:targetActivity=".MainActivity"
            android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
            <intent-filter>
                <action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
                <category android:name="android.intent.category.HEALTH_PERMISSIONS" />
            </intent-filter>
        </activity-alias>
</manifest>

Expected behavior

I want to prevent the dialog This app can't access Health Connect from appearing.

Actual behavior

I tried to catch a exception of requestAuthorization method by a log tool.
But I could not get nothing.

Flutter doctor

[✓] Flutter (Channel stable, 3.19.3, on macOS 14.2.1 23C71 darwin-arm64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.88.1)
[✓] Connected device (2 available)
[✓] Network resources

@takashi11171117 takashi11171117 added the bugfix a bug fix label May 8, 2024
@tantzygames
Copy link

Here is more information about the message you're getting:
https://developer.android.com/health-and-fitness/guides/health-connect/publish/request-access

Have you submitted this request form and been given permission to access Health Connect from Google?
https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true

@takashi11171117
Copy link
Author

@tantzygames Thanks!, I was approved the request form.
And My app can get step count in Android 14.
I applied getting step permission.

I need only step count and I wrote this line in AndroidManifest.
<uses-permission android:name="android.permission.health.READ_STEPS"/>

@tantzygames
Copy link

tantzygames commented May 10, 2024

I had to make some changes to get it working on Android 14 which have stopped it working properly on 13 and lower. I think we still need the flutter_health_connect for 13 and lower even though it crashes in 14. I will stop hijacking your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix
Projects
None yet
Development

No branches or pull requests

2 participants