Hello I am develop video player with android gallery. I receive URI from gallry. and I need to display video title, when play video. so if content has not title meta data. I
Since none of the answers really solve the questions, i put my solution here, hope it will be helpful.
String fileName;
if (uri.getScheme().equals("file")) {
fileName = uri.getLastPathSegment();
} else {
Cursor cursor = null;
try {
cursor = getContentResolver().query(uri, new String[]{
MediaStore.Images.ImageColumns.DISPLAY_NAME
}, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
fileName = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
Log.d(TAG, "name is " + fileName);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}