I want to show my steps in android widgets, so I need to fetch data in background, when testing it in emulator, it crashing with this error
android.os.RemoteException: com.softconstruct.vigohealth must be in foreground to read the following data types [Steps, StepsCadenceSeries]
but when I test in real device downloaded from google internal testing it shows
android.health.connect.HealthConnectException: java.lang.SecurityException: Caller does not have permission to read data for the following (recordType: class android.health.connect.datatypes.StepsRecord) from other applications.
Flutter doctor
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Version 10.0.22631.3593], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 2023.3)
[√] VS Code (version 1.89.1)
[√] Connected device (5 available)
[√] Network resources
Device / Emulator and OS
Describe the bug
I want to show my steps in android widgets, so I need to fetch data in background, when testing it in emulator, it crashing with this error android.os.RemoteException: com.softconstruct.vigohealth must be in foreground to read the following data types [Steps, StepsCadenceSeries]
but when I test in real device downloaded from google internal testing it shows android.health.connect.HealthConnectException: java.lang.SecurityException: Caller does not have permission to read data for the following (recordType: class android.health.connect.datatypes.StepsRecord) from other applications.
Flutter doctor
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Version 10.0.22631.3593], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6) X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools