当我从子活动返回时,不会在 mainActivity 中调用 onActivityResult。我在子活动中使用完成()。你能告诉我原因吗?
提前致谢。
主要活动
private void goToHomePage() {
if(connected){
basket.putString(key, "dummy");
Intent i = new Intent(Splash.this,HomePage.class);
i.putExtras(basket);
startActivityForResult(i,0);
}else{
alert();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
basket = data.getExtras();
Log.i("Splash","on activity result...");
if (resultCode == RESULT_OK){
switch(requestCode){
case 0:
wifi.disConnect();
break;
}
}
}
儿童活动
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
Log.i("HomePage","onKeyDown");
sendBack("close");
}
return super.onKeyDown(keyCode, event);
}
public void sendBack(String command) {
Intent sendBack = new Intent();
Bundle basket1 =new Bundle();
basket1.putString("command", command);
sendBack.putExtras(basket1);
setResult(RESULT_OK, sendBack);
finish();
}