I am making a library for unity that can pick image from android gallery and can show in unity. how can i get the path of image of android gallery for kitkat?
Asked
Active
Viewed 1,667 times
1 Answers
0
I implemented a plugin for that. Here is some code to get image path:
private static void processImageFromGallery(Intent intent) {
Uri selectedImage = intent.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = UnityPlayer.currentActivity.getContentResolver().query(selectedImage, filePathColumn, null,
null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
}

Juanjo Vega
- 1,410
- 1
- 12
- 20
-
Is this for Kitkat ? this is not working for kitkat version. :( – Golam Mostofa Aug 24 '15 at 17:33
-
I'm not sure. I implemented that time ago and haven't tested it lately again. Maybe this helps: http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content – Juanjo Vega Aug 25 '15 at 09:52