Which one is better and why?
This one:
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); ... }
or this:
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { // do not call super.onActivityResult() ... }
In short super(). onActivityResult() is use to handle the error or exception during execution of Intent.
When you done with the subsequent activity and returns, the system calls your activity's onActivityResult() method. This method includes three arguments: @The request code you passed to startActivityForResult() . @A result code specified by the second activity.
The first one is better.
It's more consistent with other event functions in the Activity
API, it costs you nothing (the code you're calling does nothing at the moment), and it means you don't need to remember to add the call in the future when the behaviour of the base class changes.
Edit
As Su-Au Hwang has pointed out, my prediction about the behaviour of the base class changing in the future has come true! FragmentActivity
requires you to call the method on super
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With