I created a loadpage with a background and a progress bar and when it finishes loading, it starts the main class but the loading screen is not showing up. It is just a black screen while it loads and then the main screen. I put all the work in the onResume and I also tried onStart with no luck
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loadpage);
//get rid of title bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(1);
}
@Override
public void onResume() {
super.onResume();
words = WordList.sharedWordList(this);
if(generatedLevels==null)
{
generatedLevels = new ArrayList<PuzzleMZLen>();
}
if(!p.isAlive())
{
p.start();
}
Intent i = new Intent(getApplicationContext(), Main.class);
startActivity(i);
}
thanks in advance
You have to use AsyncTask for this kind of work.Your layout is populated after the completion of the loading.So you are watching black screen.
Use onPreExecute
of AsyncTask
class to show the progress bar. And write loading code in the doInBackground
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With