I am developing an app which runs has a basic UI and service which can receive emergencies'. If the user is in the UI and presses home or Back a notification appears and the service continues to run. If an emergency is received by the service I want to open the Activity into the UI. To do this I have to use startActivity in the service with the Intent flag FLAG_ACTIVITY_NEW_TASK.
But this means that, if the UI is still running in the background, it doesn't get re-opened. Many of my UI interactions from that point onward seem to happen on the old, hidden UI not the new UI which is open. Also If i close the current UI I sometimes have the old UI behind it.
I would like that from a service I can either bring the old ui to the front OR open a new one, depending whether or not the old UI is still running.
I have tried using FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY_NEW_TASK together to both clear any other instances of the UI then open the UI in a new task but CLEAR_TASK is API 11 and over; my app supports 10.
Any help on the above is appreciated.