Application Crashed When Pressing Back Button on Android Camera Intent?

I don't think this is coming from your app. You can try to surround the whole onActivity result code in a try/catch block. I think what you are experiencing is a Camera bug on some of the phones.

Also try to try around different combinations of the extras you are sending on startActivityForResult intent Also always check the result code before you do anything. You don't want to make the same code if the result is canceled(Activity. RESULT_CANCELED) or ok (Activity.

RESULT_OK ) also there is a bug where the result doesn't come in the EXTRA_OUTPUT (i think it was named like that) but instead it comes as an Uri in intent.getData(). Extra output is you providing a path where to save the file and the uri return is usually the image saved in the default camera location. Its a bit different as you will see You are not using flags atm but you should if you want the image location as a result.

Search stack for some sample code for the extras.

I don't think this is coming from your app. You can try to surround the whole onActivity result code in a try/catch block. I think what you are experiencing is a Camera bug on some of the phones.

Also try to try around different combinations of the extras you are sending on startActivityForResult intent. Also always check the result code before you do anything. You don't want to make the same code if the result is canceled(Activity.

RESULT_CANCELED) or ok (Activity. RESULT_OK ) also there is a bug where the result doesn't come in the EXTRA_OUTPUT (i think it was named like that) but instead it comes as an Uri in intent.getData(). Extra output is you providing a path where to save the file and the uri return is usually the image saved in the default camera location.

Its a bit different as you will see. You are not using flags atm but you should if you want the image location as a result. Search stack for some sample code for the extras.

I surrounded my onActivityResult() with try/catch block, and it returned java.lang. NullPointerException when I press back button, so on catch block I left it blank, so the application won't crash. Thanks :D – Falmesino Jul 8 at 9:43 well read up a bit on handling exceptions if you aren't really familiar with them, but the right thing here is actually as I said to check the result code and if it is Activity.

CANCELED than to skip the code you have for getting the image (with a simple case or if statement) so the exception isn't thrown in most of the cases. – DArkO Jul 8 at 12:56.

The NullPointerException is caused by your code assuming that data.getExtras(). Get("data") will return something. This is an entirely undocumented parameter and on many (most) devices will return null.

If, as it appears, you're trying to get a thumbnail, you can try something like this, which tries both known (to me, anyway) ways in which to extract a thumbnail from the results of the Camera Intent. Bitmap thumb; if (data.getData()! = null) { try { Uri uri = data.getData(); thumb = Images.Thumbnails.

GetThumbnail(getContentResolver(), Long. ParseLong(uri. GetLastPathSegment()), Images.Thumbnails.

MICRO_KIND, null); } catch (Exception typeNotSupported) { } } if (thumb == null) { thumb = (Bitmap) data.getExtras(). Get("data"); } } Incidentally I think there's another bug - your onActivityResult should also test that resultCode is OK - if the user cancels from the Camera I believe onActivityResult will still be called. I hope that's useful.

Also there is a bug where the result doesn't come in the EXTRA_OUTPUT (i think it was named like that) but instead it comes as an Uri in intent.getData(). Extra output is you providing a path where to save the file and the uri return is usually the image saved in the default camera location. Its a bit different as you will see.

You are not using flags atm but you should if you want the image location as a result.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions