I've used a splash screen and progress bar in my Android App.But after splash disappears,then next screen becomes black before switching to my main activity. But I don't want black screen.Can anyone please explain what's going on here and how can I prevent that black screen ? This is my Splash Java class.
public class Splash extends AppCompatActivity {
private ProgressBar mProgress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mProgress = (ProgressBar) findViewById(R.id.splash_screen_progress_bar);
new Thread((new Runnable() {
@Override
public void run() {
doWork();
startApp();
finish();
}
}
)).start();
}
private void doWork() {
for (int progress = 0; progress < 100; progress += 10) {
try {
Thread.sleep(5500);
mProgress.setProgress(progress);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void startApp() {
Intent intent = new Intent(Splash.this, MainActivity.class);
startActivity(intent);
}
}