question

martinkeywood avatar image
martinkeywood asked

App crashes trying to pick an Image

Hi, I am using the emulator to try and test an app I have on other Android Tablets but it crashes with the following at the point it would show the Image Gallery to allow the user to select an image. android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK typ=image/* } Is this usage of Image Gallery valid on Kindle Fire's? I don't have one physically, just the emulator, so that may be a silly question :( Thanks Martin
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Samuel@Amazon avatar image
Samuel@Amazon answered
Hello Martin, Kindle Fire emulator supports gallery app as well. Please submit a contact us( https://developer.amazon.com/help/contactus.html) to Amazon support team if you face any issue in accessing this. One of our support engineers will assist you. Thank you.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

appmaya avatar image
appmaya answered
I also have the same problem. I have this app working on multiple phones and tablets (Samsung Galaxy SII, Next 7, etc.) but when I test on a Kindle Fire HD 8.9, the app crashes when it returns from the "Photo Selection" activity. I say this because the Kindle Fire HD does not seem to have a Gallery App like in other Android Platforms. I am using the Cursor to retrieve the exact path to the image so that it can e read into a bitmap. The code I have to handle a picture selection and the Activity result is as follows: public void LoadPhotoFromGallary() { final int ACTIVITY_SELECT_IMAGE = 1234; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), ACTIVITY_SELECT_IMAGE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case 1234: if(resultCode == RESULT_OK){ Uri selectedImageUri = data.getData(); // URI of the photo //get the absolute path and store in class variable photoFilePath = getPath(selectedImageUri); // PATH to the photo ApplyPhotoColorAndBorderTransforms(); } break; } super.onActivityResult(requestCode, resultCode, data); } public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(uri, projection, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } Do you have an example of how one can select an Image/Picture/Photograph that has either been downloaded from the web or copied to the device by the user or captured using the camera. Thank you. Message was edited by: appmaya
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sachin@Amazon avatar image
Sachin@Amazon answered
One way to accomplish what you want is to create a bitmap directly from the URI. For instance, you could do this: try { final Bitmap bitmap = Media.getBitmap(this.getContentResolver(), selectedImageUri); } catch (FileNotFoundException e) { Log.d(LOG_NAME, e.toString()); } catch (IOException e) { Log.d(LOG_NAME, e.toString()); You wouldn't have the direct path to the image, but you would have the image in a bitmap, which might be your ultimate goal. Another thing to consider is whether you need a path to the image at all. A lot of the Android API doesn't require a path, just a URI. For instance, you could use ImageView.setImageURI(selectedImageUri) in order to display a selected image. Hope this helps. Thank you.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

michaeltractive avatar image
michaeltractive answered
Same issue here. Although getting the image directly might be a solution if you need just the bitmap. However I want to upload the image to a server using its filename, so this is not really working for me. Is there any chance you can retrieve the correct filename for an image through the ACTION_GET_CONTENT intent? I just get in the data.getData() a filename in the form file:///mnt/sdcard/Download/somepic.jpg If i try to access it the content is not found. But its working on a normal android device (N4, HTC-Desire,...) I appreciate any help, cause I am really stuck here. br Mike
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
Hi MIke, Uri selectedImageUri = data.getData(); img.setImageURI(selectedImageUri); this is working fine!! lets check couple of things which would be better for you //File Manager filemanagerPath - selectedImageUri.getPath(); //Media Gallery path imgPath = getPath(selectedImageUri); public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(uri, projection, null, null, null); if(cursor!=null) { int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } else return null; } Print both filemanagerPath & imgPath and check which one is right for you.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

michaeltractive avatar image
michaeltractive answered
Thank you for your reply. I was able to resolve my issue by using this awesome github project: https://github.com/coomar2841/image-chooser-library
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Michaeltractive, Thank you for letting us know that your problem is solved. Thanks for sharing the link of a good project.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.