"Failure Delivering Result " - Onactivityforresult

Failure Delivering Result - onActivityForResult

First of all, you should read my blog post for more information (it talks about why this exception happens and what you can do to prevent it).

Calling commitAllowingStateLoss() is more of a hack than a fix. State loss is bad and should be avoided at all costs. At the time that onActivityResult() is called, the activity/fragment's state may not yet have been restored, and therefore any transactions that happen during this time will be lost as a result. This is a very important bug which must be addressed! (Note that the bug only happens when your Activity is coming back after having been killed by the system... which, depending on how much memory the device has, can sometimes be rare... so this sort of bug is not something that is very easy to catch while testing).

Try moving your transactions into onPostResume() instead (note that onPostResume() is always called after onResume() and onResume() is always called after onActivityResult()):

private boolean mReturningWithResult = false;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mReturningWithResult = true;
}

@Override
protected void onPostResume() {
super.onPostResume();
if (mReturningWithResult) {
// Commit your transactions here.
}
// Reset the boolean flag back to false for next time.
mReturningWithResult = false;
}

This might seem a little weird, but doing this sort of thing is necessary to ensure that your FragmentTransactions are always committed after the Activity's state has been restored to its original state (onPostResume() is guaranteed to be called after the Activity's state has been restored).

Failure delivering result on activity result

Shouldn't you override this instead?

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
}

onActivityResult: Failure delivering result ResultInfo

In general you should not use !! in your code. The double exclamation was chosen to scream at you, like in don't use it!!. When you use !! you are basically disabling one of the nicest Kotlin features - null safety.

But in your case this is not the root of your problem.

As we can see in the log you have an instance of the mPresenter referenced as c.d.a.a.a.e@97eb6e3

Then in the crash log we see

 Caused by: java.lang.NullPointerException
at c.d.a.a.a.d.a(:66)
at c.d.a.a.a.e.f(:34)
at com.googlemvp.signin.ui.LoginActivity.onActivityResult(:73)

Notice that the call log goes from bottom to top and from your activity line 73 we go inside the mPresenter line 34 and then to some other class c.d.a.a.a.d.a line 66 where the actual NullPointerException happens.
You should follow this log and fix the null problem in that third class.

Setting bitmap via onActivityResult: Failure delivering result

I had to declare the bitmapImages = new ArrayList<>(); outside of the switch statement... :|

Kotlin Failure delivering result

Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'void
android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a
null object reference

Your ivIcon is null so it throws NullPointerException. Please make sure it exists.



Related Topics



Leave a reply



Submit