android - Start two activities simultaneously one in foreground other in background -
i have 2 activities splashscreen , mainactivity.
mainactvity download data , show it.
now want start both activities on application start, mainactivity in background , splashscreen in foreground , when data of mainactivity download complete want make mainactivity foreground , finish splashscreen.
i have seen many solution no 1 going in situation. please give me suggestion or example .
i think it's better make splash screen download data , when completed show new activity (mainactivity). in onstart metod use downloaded data stored on phone.
your example: way can have resolve way start mainactivity first , onstart start splashscreen:
class splashscreen extends activitiy { public void onstart() { eventbus.register(this); } @subscribe public void finisheddownload(finisheddownloadevent) { this.finish() } } class mainactivity extens activity () { public void onstart () { open(new intent(splashscreen.class)); // have download(); } public void download (onfinish onfinish) { ... download eventbus.post(new finisheddownloadevent()); } }
i forgot:
class eventbus { private final static bus instance = new bus(); public static void register (object obj) { instance.register(obj) } public static void post (event obj) { instance.post(obj) } }
Comments
Post a Comment