Skip to content

[app_usage, ^3.0.1] _lastForeground field is coming 0 for various apps #1138

Open
@Amandeepnamdev

Description

@Amandeepnamdev

Plugin Name

app_usage

Plugin Version

^3.0.1

Device

Google pixel 7 pro API 34

Operating System

Android 14

Describe the bug

I am using the app usage but the _lastForeground field is coming as 0 for various app and I am not able to use it. Even for pre-installed apps it is coming as zero.
For some apps it is right.
For example I have attached screen shot for youtube. Its usage time is not zero because I have recently used it but its last forground time is showing 0.
please look into this issue.

Image Image

Steps to Reproduce

Use the -
List currentStates = await AppUsage().getAppUsage(startDate, endDate);
then printout the currentStates , lastforground time will be 0 even for the apps which are recently used.

Expected Behavior

last for ground time should be shown to the latest time the app was used.

Actual Behavior

last for ground time is showing 0 instead of latest time used.

Flutter Logs

Screenshots

Added above.

Flutter Doctor Output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on macOS 15.1.1 24B91 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Community Edition (version 2024.2.3)
[✓] VS Code (version 1.95.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone (5). Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions