I've been a bit tormented by finding out a way to finish an activity without waiting for it to complete. I know that a simple "return;" statement will do the trick but in my architecture I can't do it.
I currently have:
public abstract class BaseFragmentActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
finish();
return;
}
}
}
and
public class MainActivity extends BaseFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* code still executed here even when parent finish(); is called */
}
}
How can I prevent the execution of the code in MainActivity once the finish() in my abstract class is called?
UPDATED CODE:
public abstract class BaseFragmentActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
finish();
return;
}
}
}
public class MainActivity extends BaseFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing()) {
return;
}
}
}
Strange thing though, the "return" seems to work, but my FragmentManager somehow launches the fragment at the end.
Try wrapping it in