Android Question Finishing various activitys

MarianoD

Member
Licensed User
First all, apologize for my english.

I have activity1, activity2 and activity3...
In activity1 and activity2 i have EditText to ask some info to user.

A button in activity1, save editetext info in variables, and then i make startactivity(activity2)

Activity2 has more edittext, and a button... when i press this button i save this info in variables, and make startactivity(activity3)

I do know how to finish the current activity, with activity.finish, but my question is:

How can from inside activity3, finish activity 1 and 2?

Activity3 has a confirmation button... i save all info to database.. and want user go to FIRST screen, buuuut when i finish activity3 (activity.finish) obviusly the user go to activivity2 :(

Hope you understand me.

Thanks.
 

MarianoD

Member
Licensed User
Thanks for quick reply!

I have declared variables in both act1 and act2 that i use in act3 confirmation button... and i also need the user to move from act3 to act2... or from act2 to act1... to review data entered, using back key.

So i suppose if i use act1.finist before open act2, then i lost act1 values, its correct?

I need some way to finish act1 and act2 from inside act3 when user confirm data anda i save to database, its posible?

Thanks again.
 

klaus

Expert
Licensed User
You should declare the variables in Process_Globals in the first Activity.
Why do you have 1 EditText in Activity1, others in Activity2 and a confirmation in Activity3.
Can't this be done in one Activity ?
You could post your project as a zip file so we could see what exactly you want to do.
 

MarianoD

Member
Licensed User
I have some edittext in act1 and others in act2 because i grouped similar info, and because they are a lot of edittext that i need to use, and in cell phone the small screen dont allow me to put all editttext in one unique activity.

Maybe, as you say, i need to declare all variables in first activity (now i have some variables in act1 and some variables in act2) and close each activity before open new one, and keep edittext info in those variables, and if this variables has values, then load into esittext when user goes back and forward throgh activitys, before confirm...

But, anyway, can i close an activity from other activity? there is some kind of : app.activities.finish("act2) ?
I will try... Thanks.
 

klaus

Expert
Licensed User
As already said, you cannot finish an activity from another ons !!!
As you have the data in variables you can set their values to the EditTexts when you come back to an avtivity.
 

MarianoD

Member
Licensed User
Ok Klaus, i will try to declare variables on process_globals of first activity, and then store and use this variables when user move through activitys.

Thank you very much!
 

klaus

Expert
Licensed User
Set the EditText.Text values to the variables in Activity_Pause this updates the values when you leave an activity.
Set the EditText.Text values in Activiy_Resume to update their content when you come back to the activity.
 

MarianoD

Member
Licensed User
Thank you, i use global variables and set edittext from variables, and finish each activity before open de next, and works great!
 
Top