carp-dk / carp-dk/flutter-plugins

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

Open
#1,138 0 comments 0 reactions 0 assignees View on GitHub
app_usage bugfix
Dominant language
Dart
Stars
608
Forks
735
Avg merge
1m
Merged PRs (30d)
3

Description

### 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

```shell

```

### Screenshots

Added above.

### Flutter Doctor Output

```shell
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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.