-
Notifications
You must be signed in to change notification settings - Fork 675
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 8.0.0] ActivityNotFoundException when requesting for permission #800
Comments
It seems to work with emulators using Android SDK 33 Google Play. |
OS: Android 14 Getting the same exception. It seems to be global SDK 34 problem |
While I can reproduce this error in the emulator using Android 14, I have not found a way to fix it yet. Any input is appreciated! |
@hoffmatteo It seems google did some changes for android14 and HealthConnect is now a part of OS. |
Same issue here. I can reproduce it on a physical device (Pixel 5a) and an emulator with Android 14. Things that I tried to fix the issue:
None of it helped so far. By the way, https://github.com/imdzx/flutter_health_connect has the same issue. |
Same issue here Pixel 6A since upgrade to Android 14:
|
Checking in here on some progress I've made. First, we know this was working before in Android SDK 33. In Android SDK 34, the health connect framework is built into the OS. I thought maybe they changed the name of the activity. So I started from the idea that I was implementing Health Connect as a native Android developer. Here is the relevant developer page for implementing health connect in Android: Note that it does require additional permissions in the manifest for Android SDK 34. So I added that to my app and it still has the same exception. We will need to update this plugin with those details though.
These permissions are actually there to give the Health Connect app a way to link back to the privacy policy of your app. For a minute, I thought maybe the "no activity found" error might be referring to HC not being able to find the privacy policy activity. Next, I found their code sample and verified that on the same Android 34 test device I am able to request permissions successfully. This means that we have a working code sample that shows how to request permissions. So we should be able to just update the https://github.com/android/health-samples/tree/main/health-connect/HealthConnectSample Here is where I'm stuck... I'm not a native Android guy. I came from iOS and work on Flutter apps now. I can read the code but, geez, there seem to be multiple ways to open an activity in Android. The code sample from Google looks like it uses Jetpack Compose and a bunch of libraries and code patterns to open the HC activity. It's completely different to how this plugin works so I haven't been able to adapt the code. It also feels like Jetpack Compose might be heavy handed for a Flutter app that has minimal native code. I'm hoping by sharing this info someone with more Android native experience can help out. |
Check #834, it is an attempted fix for this issue. Any changes or improvements are welcome. |
hello, working on a Cordova plugin, using Java, so not the same environment but I get exactly the same issue on SDK 34, physical device. If you manage to solve it, please inform what was causing the problem and how you fixed it. You will make many people happy! |
OK I have the answer now. In Android 14 the use of startActivityForResult has been completely phased out and you have to use the new workflow, with registerForActivityResult. This was solved by @eliasteeny in his commit and also solved my problem (or at least learning about it). |
If you use this solution as a freezed package on the pubspec yaml you can make this error go away. You can read a bit more in here #834 (comment) |
OS: Android 14
Device: Emulator (Pixel 7 Pro, Android SDK 34 Google Play)
When trying to request for permissions like following:
the app crashes with exception:
My AndroidManifest.xml:
The Health Connect app is installed on the emulator. Any idea what I am missing?
The text was updated successfully, but these errors were encountered: