flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[Health 9.0.0] Required to update MainActivity to extend FlutterFragmentActivity even for Android 12

Open tejasbadone opened this issue 5 months ago • 1 comments

Device / Emulator and OS

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

  • Device: Realme 7 Pro [RMX2170]
  • OS: Android 12

Describe the bug

At first, requestAuthorization() for Health Connect didn't show the permission screen(Health Connect was already installed). After updating MainActivity.kt to extend FlutterFragmentActivity() instead of FlutterActivity(), it worked. However, I'm puzzled if this change is meant only for Android 14 devices, as I had to make this update even on my Android 12 device.

To Reproduce

Steps to reproduce the behavior - Run the app on Android 12 with Health Connect installed and without updating the MainActivity.kt. Expected result:

Expected behavior

It should have shown the permission screen for the Health Connect app without updating the MainActivity.kt on Android 12.

Actual behavior

D/ProfileInstaller( 4944): Installing profile for com.example.health_9_test
V/AutofillManager( 4944): requestHideFillUi(null): anchor = null
W/OplusExSystemServiceHelper( 4944): checkOplusExSystemService intent getComponent is null
I/flutter ( 4944): >> trying to get permissions for [ACTIVE_ENERGY_BURNED, BASAL_ENERGY_BURNED, BLOOD_GLUCOSE, BLOOD_OXYGEN, BLOOD_PRESSURE_DIASTOLIC, BLOOD_PRESSURE_SYSTOLIC, BODY_FAT_PERCENTAGE, HEIGHT, WEIGHT, BODY_TEMPERATURE, HEART_RATE, STEPS, DISTANCE_DELTA, RESPIRATORY_RATE, SLEEP_AWAKE, SLEEP_ASLEEP, SLEEP_LIGHT, SLEEP_DEEP, SLEEP_REM, SLEEP_SESSION, WATER, WORKOUT, RESTING_HEART_RATE, FLIGHTS_CLIMBED, NUTRITION] with permissions [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
I/FLUTTER_HEALTH( 4944): Permission launcher not found
I/flutter ( 4944): >> isAuthorized: false

Flutter doctor

[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.19045.3930], locale en-IN) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1) [√] Chrome - develop for the web [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2020.3) [√] VS Code (version 1.86.0) [√] Connected device (4 available) [√] Network resources

tejasbadone avatar Feb 05 '24 14:02 tejasbadone

If the latest version requires FlutterFragmentActivity, then why is this a problem? Don't you want it to work for Android 14 and below?

I had the same issue as you, but just made sure everything was as per the example app, and now things are working fine.

This comment was useful: https://github.com/cph-cachet/flutter-plugins/issues/888#issuecomment-1931983263

hagen00 avatar Feb 15 '24 09:02 hagen00