traccar-client-android icon indicating copy to clipboard operation
traccar-client-android copied to clipboard

Remove sticky notification in hidden mode

Open sajjadG opened this issue 7 years ago • 10 comments

Sticky notification (#46) is not removed/disabled in hidden mode.

sajjadG avatar Apr 16 '17 22:04 sajjadG

What Android version are you using?

tananaev avatar Apr 16 '17 23:04 tananaev

I'm using LineageOS 14.1-20170329 android version 7.1.1

sajjadG avatar Apr 16 '17 23:04 sajjadG

What version of Traccar Client are you using?

tananaev avatar Apr 16 '17 23:04 tananaev

Traccar Client 4.1 (hidden mode).

sajjadG avatar Apr 16 '17 23:04 sajjadG

Just tested it on 7.1.1 and indeed the notification is there. I don't think it's possible to do anything about it. Sticky notification is required for foreground services. If we don't make service foreground, system would kill it after some time.

tananaev avatar Apr 17 '17 00:04 tananaev

What you can do is block notifications from Traccar Client app. Slide the notification and block it.

tananaev avatar Apr 17 '17 00:04 tananaev

As you said foreground services MUST have a notification. https://developer.android.com/guide/components/services.html#Foreground

A solution may be to start the service in background and schedule a runner to check if it's running and re-run when needed (only for hidden mode albeit).

sajjadG avatar Apr 17 '17 09:04 sajjadG

How do you "schedule a runner"?

tananaev avatar Apr 17 '17 10:04 tananaev

With AlarmManager. https://developer.android.com/training/best-background.html https://developer.android.com/training/scheduling/alarms.html

Is it OK if I implement it and request a "pull request"?

sajjadG avatar Apr 17 '17 13:04 sajjadG

It's already implemented. The problem that it won't stop doze mode on recent versions of Android.

tananaev avatar Apr 17 '17 22:04 tananaev