0

I'm using the Yalantis library "UCrop" in my android app to crop, scale and rotate images coming from the built-in smartphone camera. When I call uCrop.start(this) the UCropActivity launches and in the upper left corner the cancel button appears as a little cross.

Now when I press the cancel button, the app crashes with the following Exception:

FATAL EXCEPTION: main
Process: com.myapp.myappname, PID: 25034 
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.myapp.myappname/com.myapp.myappname.myActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'int
java.lang.String.length()' on a null object reference

When I press the softkey-back-button I return savely to myActivity.

Now the question is, how can I influence the behavior of the cancel button so that it either behaves like the back button or restarts myActivity in a way that doesn't cause an exception?

In the SampleActivity from the ucrop sample-project the cancel button behaves as I would expect.

Speedy
  • 1
  • 3

1 Answers1

0

I found a way to fix this issue I see with my app:

adding a return true; after the line onBackPressed(); in the onOptionsItemSelected(...) method inside UCropActivity class will do the trick for me.

Don't ask me why it would behave different when I press the softkey back button.

Speedy
  • 1
  • 3