开发者

Null intent in onActivityResult(int requestCode, int resultCode, Intent data)

I'm starting an Activity for result. And on that Activity's onBackPressed() event I'm setting the intent and result.

@Override
public void onBackPressed() {

    super.onBackPressed();
    Intent intent = new Intent(BrowseSome.this,
            ConfigurationSome.class);
    intent.putParcelableArrayListExtra("SomeList", somethings);
    setResult(RESULT_OK, intent);

}

But in my onAcivityResult(int requestCode, int resultCode, Intent data) I'm getting null Intent. Why is it so?

Earlier is used to do this on a Button click event and it worked fine. But i have removed this button from the activity and now i want the result to be set onBackPressed() event.

-Thanks开发者_Python百科


your call to super.onBackPressed(); is preventing the code below it from being called (it calls finish() on your activity). Try rearranging your code to:

@Override
public void onBackPressed() {       
    Intent intent = new Intent(BrowseSome.this,
            ConfigurationSome.class);
    intent.putParcelableArrayListExtra("SomeList", somethings);
    setResult(RESULT_OK, intent);
    super.onBackPressed();

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜