Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

startActivityForResult inside startActivityForResult

If I call startActivityForResult and the activity that starts is also calling startActivityForResult on another activity,
is it possible that the first activity will be stopped ?
Is there a way to prevent it from happen?
What context should I pass each intent I create?

some code to figure the process

intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivityForResult(intent, AbstractSettingsActivity.SETTINGS_ACTIVITY_REQUEST_CODE);

// this is inside the Settings activity
Intent intent = new Intent(getBaseContext(), SettingsTabsActivity.class);
startActivityForResult(intent, CUSTOMIZE_TAB_REQUEST_CODE);
// at this point i got ondstroy on main activity - main is not the root
like image 406
Chen Kinnrot Avatar asked Nov 04 '22 12:11

Chen Kinnrot


1 Answers

In any case (either its startActivity or startActivityForResult), when you start a new activity, your current Activity will go into stopped state by raising its onStop method. Its the way Android's Activity life-cycle is designed. It has nothing to do with a type of context.

However, if you don't want to occur onStop, then perhaps you may try emulating the expected view(s) through Dialogs which will cause your Activity to reach up till its onPause state.

like image 188
waqaslam Avatar answered Nov 15 '22 01:11

waqaslam