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

PlatformException when Health Connect is not installed #10

Open
koenmuilwijk opened this issue Apr 11, 2023 · 3 comments
Open

PlatformException when Health Connect is not installed #10

koenmuilwijk opened this issue Apr 11, 2023 · 3 comments

Comments

@koenmuilwijk
Copy link

When Google Health Connect is not installed on the device the plugin gives the following exception when calling any method (including the HealthConnectFactory.isApiSupported() method. I verified this same behaviour happens in the provided example app.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(NO_ACTIVITY, No activity available, null, null)

This is because there is no activityContext available while this is asserted on line 71 in FlutterHealthConnectPlugin.kt.

I believe the correct behaviour would be to not require the activityContext for the following method calls: isApiSupported, isAvailable, and installHealthConnect.

@owjoh
Copy link

owjoh commented Jul 4, 2023

@koenmuilwijk Did you ever figure out a work-around?

@koenmuilwijk
Copy link
Author

@owjoh not really, no.

I have this hacky workaround which is far from perfect. However, this library seems not able to work in production atm (see the other ticket on that) so that's the next show stopper you'll run into.

static installHealthConnect() async {
    //return HealthConnectFactory.installHealthConnect();
    launchUrl(
      Uri.parse("market://details?id=com.google.android.apps.healthdata"),
      mode: LaunchMode.externalApplication,
    );  
  }

And then wrap the isApiSupported and isAvailable into try-catch's.

@Fethi-Hamdani
Copy link

Any updates on This?

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

No branches or pull requests

3 participants