switching between activities

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

switching between activities

Postby gbaldeck » Fri Nov 26, 2010 8:28 pm

Hi I'm writing an app that has multiple activities. Right now it starts at the home screen, then when the user presses a button it starts a new activity and goes to another screen, then the user enters in information and presses a button to start another activity and another screen.

I have a menu setup so that from whatever the activity the user is in they can get back to the home screen. What I want it to do is kill all the current activities and just take the user right back to the home screen, so there is only one activity running again. How can I do this?
Once Poster
Once Poster
Posts: 1
Joined: Thu Nov 25, 2010 5:54 pm


Re: switching between activities

Postby jinelong » Mon Dec 27, 2010 11:17 am

i believe you are going to use intent to switch between activities.

say you start with activity A, go to activity B, and then go to activity C
when you return from activity C, you wanna skip activity B, directly going back to A

Code: Select all
//in activity B
//when you are about to jump to C
startActicity(new Intent().setClass(B.class, C.class));

//here, by explicitly calling "finish()", you will remove current activity from the stack

//when you click "back" in activity C, you wont see B anymore

hope this answers your question
Posts: 2
Joined: Wed Dec 22, 2010 7:54 am


Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests