Android: keep alert in front, so that the user must respond
<p>My application shows an alert that the user must respond to before continuing to do other things. I'm trying to figure out the best way to implement this. Using an Activity for the alert isn't quite working.</p>

<p>In my current implementation, the alert is activity (A). When another activity from the same package is started and onStop is called, it starts itself again using FLAG_ACTIVITY_REORDER_TO_FRONT so that it's always at the top of the stack. This works as described, unless Activity A uses Theme.Dialog or Theme.Translucent.</p>

<p>Modified log:</p>

<pre><code>Activity A created
Activity A started
Activity A resumed
Activity A paused
Activity B created
Activity B started
Activity B resumed
Activity B gains window focus
Activity A stopped
Top activity in stack is Activity B, so Activity A relaunches itself
Activity B paused
Activity A started
Activity A resumed
</code></pre>

<p>The top activity in the stack should be Activity A, however Activity B remains in the foreground.</p>

<p>Another implementation detail: my application is not for a phone, so I'm not concerned with a back button finishing the activity or interactions with other apps. Still, I agree that on principle I should prevent such problems anyway, so in my code I check whether the activity that has come in front is from the same package (i.e. from our code base). This should work around the theoretical problem of interfering with other apps.</p>

<p>Is there a way to bring Activity A into focus? I understand that this is unusual behavior, but it is necessary for Activity A to remain in the foreground until it is deliberately finished.</p>

<p>I'm also open to suggestions about a completely different and better approach!</p>

<p>FWIW, I'm running 2.2.</p>

<p>(Cross-posted from <a href="http://groups.google.com/group/android-developers/browse_thread/thread/d46fd7d59abe15a0" rel="nofollow">http://groups.google.com/group/android-developers/browse_thread/thread/d46fd7d59abe15a0</a>, where we got no response.)</p>
