0
我正在進行我的Surfaceview相機活動,我想從本地路徑的Uri獲取MimeTye文件,同時調用圖庫可以從Content Uri獲取MimeType,但是從相機加載無法獲取MimeType那些試圖將localPath從文件轉換成開放的內容爲下面的嘗試:如何從相機獲取MimeType?
public static Uri getImageContentUri(Context context, File imageFile) {
String filePath = imageFile.getAbsolutePath();
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Images.Media._ID },
MediaStore.Images.Media.DATA + "=? ",
new String[] { filePath }, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor
.getColumnIndex(MediaStore.MediaColumns._ID));
// Uri baseUri = Uri.parse(stringUri);
return Uri.withAppendedPath(uploadImageURI, "" + id);
} else {
if (imageFile.exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, filePath);
return context.getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
} else {
return null;
}
}
}
follwed鏈接:http://android-er.blogspot.in/2011/04/convert-uri-to-real-path-format.html但問題並沒有解決。
如何解決這個有沒有其他的解決方案來解決issue.Is有請幫我的朋友
一定要仔細閱讀http://developer.android.com/reference/android/provider/MediaStore.Images.Media.html#CONTENT_TYPE – Nepster 2015-03-06 10:40:47