android - Finish activity without waiting for completion -
i've been bit tormented finding out way finish activity without waiting complete. know simple "return;" statement trick in architecture can't it.
i 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 when parent finish(); called */ } }
how can prevent execution of code in mainactivity once finish() in abstract class 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, "return" seems work, fragmentmanager somehow launches fragment @ end.
try wrapping in
if(isfinishing()){ //code don't want execute if finish() called }
Comments
Post a Comment