Saturday, August 13, 2011

[android-developers] Re: How to close entire app?

I've used the "finish()" option - with multiple activities, it's a
great way to go.

As such:

Intent newActivity = new Intent();
// set stuff for Intent
startActivity(newActivity);
finish();

When you hit "back", the activity is finished, so it goes to whatever
previous activity was not finished. This is like a web browser having
an expired page (but Android handles it much better - you don't have
multiple browsers, multiple OS's, stateless connections, etc. so you
can do a lot more; as Mark points out, the web model is a good model
for transaction processing).

Also, make sure the activity does not display on the "recents" list,
or you might find yourself with users that start in the middle of your
transaction process...

OK, so since we helped, could you stop the REBOOT code on the web
browsers??? Or just give us names of people that do stuff like that.
Either way, I'll help pay shipping on that airmail Mark is talking
about!

@ndiiie90 - vague question. Do you have a specific problem related to
the topic?

-Jim

On Aug 12, 12:38 pm, Robert Thau <rst...@gmail.com> wrote:
> On Fri, Aug 12, 2011 at 11:17 AM, ndiiie90 <rnd...@gmail.com> wrote:
> > Hi again Mark,
>
> > I must close the entire app, because my app is a commerce application,
> > that has its own flow until the payment, and user can't go back to
> > previous screen, so whenever user has reached the last page, there are
> > options to exit the app or go back to menu again..have any idea?
>
> With the caveat that I haven't actually tried either of these techniques:
>
> If you don't want "Back" to *ever* work, then you could try having
> each Activity call finish() after starting the next.  Otherwise, you could
> think about having some sort of "transaction ID" that's passed between
> them, and have them check in onResume whether that transaction is
> over, calling finish() if so.
>
> Either way, though, disabling the "Back" button is something to be done
> with caution --- users are used to having it work a certain way, and
> violating
> those assumptions is likely to give them a seriously bad experience.
>
> rst

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment