我使用了postedDelayed 方法来刷新我的Activity,效果很好。但问题是,即使我按下后退按钮后延迟方法回调上一个活动..
//30000 毫秒后延迟刷新活动的处理程序
mHandler.postDelayed(new Runnable() {
public void run() {
dostuff();
}
}, 30000);
}
protected void dostuff() {
Intent intent = getIntent();
finish();startActivity(intent);
Toast.makeText(getApplicationContext(), "refreshed", Toast.LENGTH_LONG).show();
}
public void onBackPressed() {
super.onBackPressed();
finish();
mHandler.removeCallbacks(null);
}
protected void onStop() {
mHandler.removeCallbacks(null);
super.onStop();
}