android-gallery

Get filepath and filename of selected gallery image in Android

我是研究僧i 提交于 2019-11-26 07:35:11
问题 I am creating an app which uploads a selected image from the gallery and uploads it to a web service. The webservice requires the filename of selected image plus a base64 encoding of the file contents. I have managed to achieve this with a hardcoded file path. However, I am struggling to get the real filepath of the image. I have read around the web and have this code, but it does not work for me: public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode ==

Android : How to detect the image orientation (portrait or landscape) picked from gallery while setting on an imageview?

半腔热情 提交于 2019-11-26 04:42:59
问题 I am setting an image on the imageview picked from the gallery(camera album). If the picked image has landscape orientation, it displays perfectly but if the image in in portrait mode(i.e the image was clicked in portrait mode) it is displaying the image with a 90 degree rotation. Now I am trying to find out the orientation just before setting on imageview, but all the images are giving same orientation and same width-height. Here is my code : Uri selectedImage = intent.getData(); if

Allow user to select camera or gallery for image

半城伤御伤魂 提交于 2019-11-26 03:16:09
问题 What I\'m trying to do seems very simple, but after a few days of searching I can\'t quite figure it out. I have an application that allows the user to select multiple(up to 5) images. I\'m using an ImageView . When the user clicks on the ImageView , I\'d like to allow them the option to Select the image from the gallery, or Use the camera to capture an image. I started by using the ACTION_GET_CONTENT intent, and that works well for getting to the gallery. So then I tried using the ACTION

Android Gallery on Android 4.4 (KitKat) returns different URI for Intent.ACTION_GET_CONTENT

荒凉一梦 提交于 2019-11-25 22:29:04
问题 Before KitKat (or before the new Gallery) the Intent.ACTION_GET_CONTENT returned a URI like this content://media/external/images/media/3951. Using the ContentResolver and quering for MediaStore.Images.Media.DATA returned the file URL. In KitKat however the Gallery returns a URI (via \"Last\") like this: content://com.android.providers.media.documents/document/image:3951 How do I handle this? 回答1: Try this: if (Build.VERSION.SDK_INT <19){ Intent intent = new Intent(); intent.setType("image

How to pick an image from gallery (SD Card) for my app?

限于喜欢 提交于 2019-11-25 22:22:57
问题 This question was originally asked for Android 1.6. I am working on photos options in my app. I have a button and an ImageView in my Activity. When I click the button it would redirect to the gallery and I would be able to select an image. The selected image would appear in my ImageView. 回答1: Updated answer, nearly 5 years later: The code in the original answer no longer works reliably, as images from various sources sometimes return with a different content URI, i.e. content:// rather than