[問題]startActivityForResult搭配onBackPressed

作者: kdok123 (小天)   2015-01-07 11:50:19
A.class
onCreate:
{
Intent intent = new Intent("test1");//會跳到B.class
Bundle bundle = new Bundle();
bundle.putString("toB", "toB");
intent.putExtras(bundle);
startActivityForResult(intent, 1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
String returnValue = data.getExtras().getString("toA");
Log.e("onActivitiyResult", returnValue);
}
break;
default:
}
}
作者: c910335 (達人)   2015-01-07 12:16:00
去掉super.onBackPressed();
作者: kdok123 (小天)   2015-01-07 13:19:00
真的欸!(這句快變我的口頭禪了)另外把super.onBackPressed()放在最後面也可
作者: ssccg (23)   2015-01-07 14:01:00
原本的back處理是 回復actionbar > pop fragment > 關activity,如果自訂的流程就是要finish,那再呼叫super的沒意義.

Links booklink

Contact Us: admin [ a t ] ucptt.com