java - Showing Loading activity until main activity is fully loaded -
here code main activity loaded after oncreate method executed.
refered this closing 1 activity another
public class dictionarysscwords extends appcompatactivity implements view.onclicklistener, texttospeech.oninitlistener { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); context = this; intent myintent = new intent(dictionarysscwords.this,loadingit.class); startactivity(myintent); setcontentview(r.layout.activity_main); //all activity work loadingit.fa.finish(); //close loading activity } } now here code of loadingit activity
public class loadingit extends appcompatactivity { context context; public static loadingit fa; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_loading_it); context=this; fa = this; progressdialog dialog=new progressdialog(context); dialog.setmessage("loading please wait!!"); dialog.setcancelable(false); dialog.setinversebackgroundforced(false); dialog.show(); } } problem loadingit activity never finished , app stuck on loading screen want finish thisactivity previous acivity oncreate method executed
thanks
i feel solution not best practice. here do:
declare
loadingitactivity startup activityin
oncreatemethod, load resources needed in background (eitherasynctaskorintentserviceexample)once loading finished, finish
loadingitactivity , displaydictionarysscwordsactivity
if post loading logic, provide sample implementation.
Comments
Post a Comment