I have an Android application. I am making a loading screen with a progress bar.
I entered a delay in the onCreate method. When the timer finishes, I want to finish the current activity and start a new one.
It just gives me an exception when it calls the finish()
method.
public class LoadingScreen extends Activity{
private LoadingScreen loadingScreen;
Intent i = new Intent(this, HomeScreen.class);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loading);
CountDownTimer timer = new CountDownTimer(10000, 1000) //10 second Timer
{
public void onTick(long l)
{
}
@Override
public void onFinish()
{
loadingScreen.finishActivity(0);
startActivity(i);
};
}.start();
}
}
How can I change the code so that it ends when the progress bar is done?