0
我在嘗試調用另一個名爲HomeActivity的類時遇到了問題,因爲我需要在類MainActivity中添加消息「Please wait」。Android/Eclipse MainActivity將意圖傳遞給另一個活動
這是我的主要活動,如何插入等待消息?
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class MainActivity extends Activity {
private boolean mIsBackButtonPressed;
private static final int SPLASH_DURATION = 5000;
private Handler myhandler;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
myhandler = new Handler();
myhandler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
if (!mIsBackButtonPressed) {
Intent intent = new Intent(MainActivity.this,
HomeActivity.class);
MainActivity.this.startActivity(intent);
}
}
}, SPLASH_DURATION);
}
@Override
public void onBackPressed() {
mIsBackButtonPressed = true;
super.onBackPressed();
}
}