嘿,我在下面的代码上崩溃了。我正在尝试将 Toast 扩展一段时间,并在运行时“杀死” Toast onPause
。我究竟做错了什么?timer.cancel()
当我添加时 发生崩溃onPause
private boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
splashTread.start();
return true;
} else {
timer = new CountDownTimer(20000, 1000)
{
public void onTick(long millisUntilFinished) {toast.show();}
public void onFinish() {toast.cancel();}
}.start();
return false;
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
finish();
timer.cancel():
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
timer.cancel():
}
}