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
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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.