traccar / traccar-client-android

Traccar Client for Android
https://www.traccar.org/client
Apache License 2.0
666 stars 738 forks source link

Kill app on background for Android 13 #448

Closed bernamaxim closed 1 year ago

bernamaxim commented 1 year ago

Android 13 kill app on background, maybe notification on foreground must need runtime permission, because it not turn on automatically.

https://developer.android.com/develop/ui/views/notifications/notification-permission

IMG_20230418_194748

tananaev commented 1 year ago

Have you tried enabling it?

bernamaxim commented 1 year ago

Yes I have. But, it cannot enable.

tananaev commented 1 year ago

Looks like you're right. We need to enable it.

tananaev commented 1 year ago

Wait. I just checked the documentation again and it says explicitly:

Note: Apps don't need to request the POST_NOTIFICATIONS permission in order to launch a foreground service. However, apps must include a notification when they start a foreground service, just as they do on previous versions of Android.

So it seems like it's not required.

tananaev commented 1 year ago

Just to be sure I tested it and I can see that the foreground service is running:

Screenshot_20230418_173638

bernamaxim commented 1 year ago

Screenshot_2023_0419_075329

Are you sure to use Android 13 for testing?

tananaev commented 1 year ago

Yes, absolutely. I'm using Android 13 emulator

Screenshot 2023-04-18 at 5 56 31 PM
bernamaxim commented 1 year ago

I have tested again to make sure.

I clear memory and cache on my device and reinstall Traccar.

About 25 minutes ago I run Traccar and sweep away (to make sure running in background)

For several updates it not problem until first 5 minutes.

After waiting for 20 minutes, it not update anymore.

IMG_20230419_083544

But after I opened app, it start to update again. Execute startForeground (with process: "service started" and "network online")

Screenshot_2023_0419_082025

Note:

  1. I have make sure to set allow access all the time for GPS, use accurate location and turn off battery optimization.
  2. I have tested for 2 device with Android OS 13.
tananaev commented 1 year ago

What devices have you tested? Have you ready about your devices here?