我想在android應用程序中做一些簡單的事情。如何返回到android中的上一個活動?
如何返回上一個活動?
我試過按智能手機上的後退按鈕,但它返回到顯示應用程序菜單並退出應用程序。
我錯過了什麼?這段代碼有什麼問題?
Button qsButton = (Button) findViewById(R.id.button1);
qsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
progressDialog = ProgressDialog.show(HomeActivity.this,
"Start", "Start ...", false,
false);
int secondsDelayed = 3;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(MainActivity.this,
HomeActivity.class));
finish();
}
}, secondsDelayed * 1000);
Intent myIntent = new Intent(v.getContext(),
HomeActivity.class);
startActivityForResult(myIntent, 0);
}
});
在此先感謝您。