該程序不會調用onActivityResult,我一直在很多職位,但我不能讓它工作。活動不會調用onActivityResult
即時通訊使用Android 3.0模擬器。
這是GameScreen.java
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case 0: {
if (resultCode == Activity.RESULT_OK) {
String newText = data.getStringExtra("isRunning");
// TODO Update your TextView.
isRunning = true;
}
break;
}
}
}
public void pause(){
clickListener = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
pause.setImageResource(R.drawable.pauseafter);
isRunning = false;
Intent intent = new Intent(Gamescreen.this, Shop.class);
startActivityForResult(intent, 0);
}
};
}
的代碼這是代碼Shop.java
public void returnButton(){
resume.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
setResult(Activity.RESULT_OK,intent);
finish();
}
});
}
嘗試getIntent()而不是新的Intent()。也許它會工作 – 2012-03-27 05:58:46
好吧,它不工作'意圖intent = getIntent();'。 – 2012-03-27 06:04:58