Summary
Can I start a new activity from a background service when its application is in the background, without bringing the application to the front?
Background
Suppose I'm developing MyApp for Android. This app handles very sensitive information, so we need to lock the app when the user has been inactive for a little while.
MyApp has a service, MyService. Different user interactions with the app resets an inactivity timer in MyService. When the inactivity timer expires, the service starts a new activity, LockActivity, which acts as a screen lock for MyApp. The user has to reauthenticate herself to get past the LockActivity and resume working with the app.
This all works, with one problem: when the LockActivity is started, it brings the app to the front. Since the user may be doing something else (browsing Facebook or whatever), she will be annoyed, and rightly so.
The code I'm using for starting the activity from the background is:
Activity topActivity = magicallyFindMyTopActivity(); // This part is not important; it works though
Intent intent = new Intent(this, LockActivity.class);
topActivity.startActivity(intent);
Do you know any way to avoid this?