starting Activities from outside

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

starting Activities from outside

Postby metter » Wed Jul 08, 2009 10:03 am

Hello there

I am wondering about the way to go about starting activities.

Let's assume I have Activity A, Activity B and Activity C.

Activity B is shown. When some stuff is done, I want to show Activity C. So far no problem. BUT when the user hits back from Activity C, A should be shown, not B.
Until now I have used some hack ala "ActivityA.startActivityC" which I called from activity B. But somehow i don't believe this is the best way to go here?

A start B
B start C
C back A

Thanks! :)

Junior Developer
Junior Developer
Posts: 16
Joined: Tue Jan 06, 2009 2:00 pm


Postby serkan.dogantekin » Thu Jul 09, 2009 7:20 am

I think you can use startActivityForResult method when starting C from B, like:

in A:
startActivity(new Intent(this,B.class));

in B:
startActivityForResult(new Intent(this,C.class),START_C);

onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == START_C) {

in this manner when Activity_C "finishes", the "onActivityResult" will be called in Activity_B with the code specified in the"startActivityForResult" call. And if you call "finish" at that condition, we will be return to the Activity_A
Posts: 27
Joined: Thu Jun 04, 2009 6:12 pm
Location: Istanbul/Turkey


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests