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:

  1. declare loadingit activity startup activity

  2. in oncreate method, load resources needed in background (either asynctask or intentservice example)

  3. once loading finished, finish loadingit activity , display dictionarysscwords activity

if post loading logic, provide sample implementation.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -