[3.0.2] Health - detect installation of Google Fit
Device / Emulator and OS
- Device: One Plus 6
- OS: Android 11
Describe the bug
It's not a bug, but a help request. I can't find the way to detect if user has Google Fit installed, is there any method integrated on the library?
Flutter doctor
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Versione 10.0.19041.1348], locale it-IT)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.63.0)
[√] Connected device (3 available)
@RTsosssoldi I'm using the following package to check if Google Fit is installed in the device
import 'package:device_apps/device_apps.dart';
Add the permission in the manifest file
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
Use the following snippet
Future<bool> isGoogleFitInstalled() async {
try {
final value =
await DeviceApps.isAppInstalled('com.google.android.apps.fitness');
return value;
} catch (e) {
return false;
}
}