Thanks Dianne - I appreciate the response.

Instead of prompting for exit, I decided to capture the back button
keypress, then send the app to the background like this:

   public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_BACK)
          {
                moveTaskToBack(true);
                return false;
          }
          else
          {
              return super.onKeyDown(keyCode, event);
          }
    }

To let the user totally shut down the app, I added a menu option that
calls finish()

-Gregg

On Jul 29, 10:49 pm, Dianne Hackborn <[email protected]> wrote:
> You probably shouldn't count pressing the back button as closing the app as
> you describe here.  If there is some ongoing work that it does in the
> background, you should have a separate UI for the user to start and stop
> that work, and the ongoing notification should take the user to the
> corresponding UI.
>
>
>
> On Wed, Jul 29, 2009 at 7:20 PM, Gregg Reno <[email protected]> wrote:
>
> > I have an app that receives and stores SMS messages.  The main use is
> > to run in the background, although it does have a full GUI when
> > running in the foreground.  I'm using a notification with the
> > FLAG_ONGOING_EVENT flag so users can tell the application is running,
> > even if it's in the background.
>
> > However, the user could easily close the app by viewing the main
> > screen and clicking the back button.  The notification icon goes away,
> > but I would like to be able to warn the user that closing the app
> > would prevent it from capturing the SMS messages.
>
> > Is there any way to prompt the user if they really want to exit the
> > application when they hit the back button, and prevent the exit if
> > they say no?  Or should I take a different approach?
>
> > And a bonus question:  is there a way of receiving an SMS message, but
> > prevent it from passing on to, say, the Messenging app?
>
> > Thanks
> > -Gregg
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to