Created
August 5, 2015 15:09
-
-
Save contactsunny/4c61b1c5493a1a5ab815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intent call to select image from gallery | |
Intent intent = new Intent(); | |
intent.setType("image/*"); | |
intent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult( | |
Intent.createChooser(intent, "Select Picture"), | |
SELECT_PICTURE); | |
/***************************************************************/ | |
//Handling the returned image | |
Uri selectedImageUri = data.getData(); | |
String selectedImagePath = getPath(selectedImageUri); | |
/***************************************************************/ | |
//The getPath() function | |
public String getPath(Uri uri) throws NullPointerException { | |
String[] projection = { MediaStore.Images.Media.DATA }; | |
Cursor cursor = managedQuery(uri, projection, null, null, null); | |
int column_index = cursor | |
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |
cursor.moveToFirst(); | |
return cursor.getString(column_index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment