Why is onActivityResult() Intent data equal null?

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

  • Answer:

    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(); }

GamDroid at Stack Overflow Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.