0

I have an application that uses another library to enter password to get into the app.

It starts my.package.MainActivity and if it is locked, it will show different.lib.package.MainActivity to get password. Then it resumes to my.package.MainActivity, loads data from API and shows them.

You can show some of the data on the widget on the homescreen (here, it doesn't need password). These data are updated every +- hour from running service my.package.MyService.

When my.package.MainActivity is on the foreground, my.package.MyService is running on the background and updating data correctly.

When my.package.MainActivity on the background, my.package.MyService is started as foreground service and notification is shown to user about that. As I understood this is how it works on Oreo.

So.. when different.lib.package.MainActivity is shown I have to run service as foreground service. Otherwise I am getting

java.lang.IllegalStateException:

Not allowed to start service Intent, app is in background.

Is it possible to stop showing this notification while different.lib.package.MainActivity is on the foreground? Or I have to show notification because it is from different package? I have trouble with this because from user point of view it looks like one app is on the foreground and notification shows that the same app is running on the background.

(it is an old and huge application I am maintaing)

Vinay P
  • 617
  • 3
  • 13
KVAK
  • 1
  • Did you try this https://stackoverflow.com/a/3595241/6549598 ? – nimi0112 Jul 13 '18 at 11:27
  • This is exactly opposite problem. I can't cancel notification and stop service on the foreground - I will get IllegalStateException0 Because different.lib.package.MainActivity is on the foreground, so my.package.MainActivity is on the background, so my app according to android system is not running. I am asking if there is a way around that. – KVAK Jul 16 '18 at 06:35

0 Answers0