我得到了跟踪堆栈跟踪
04-17 12:11:56.378: D/ATRecorder(10379): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40528b78
04-17 12:11:56.408: D/WindowManagerImpl(10379): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@40520738
04-17 12:11:56.428: D/WindowManagerImpl(10379): addView, new view, mViews[1]: android.widget.LinearLayout@40525d00
04-17 12:11:56.438: D/WindowManagerImpl(10379): finishRemoveViewLocked, mViews[1]: android.widget.LinearLayout@40525d00
04-17 12:11:56.718: D/TAG(10379): Error setting camera preview: setPreviewDisplay failed
04-17 12:11:56.748: D/TAG(10379): Error starting camera preview: setPreviewDisplay failed
04-17 12:12:07.558: D/View(10379): onTouchEvent: viewFlags: 0x18004001
04-17 12:12:07.568: D/View(10379): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-17 12:12:07.588: V/MediaRecorderJNI(10379): start
04-17 12:12:07.598: V/MediaRecorderJNI(10379): getMediaRecorder E
04-17 12:12:11.632: V/MediaRecorderJNI(10379): process_media_recorder_call
04-17 …Run Code Online (Sandbox Code Playgroud) 我想将文件发送到服务器,我需要从uri获得真正的路径.
我的代码:
public String getPathFromURI(Context context, Uri contentUri) {
if ( contentUri.toString().indexOf("file:///") > -1 ){
return contentUri.getPath();
}
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}finally {
if (cursor != null) {
cursor.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
和onActivityResult:
...
imageName = data.getData();
imagePath = getPathFromURI(getBaseContext(),imageName);
Picasso.with(getBaseContext()).load(imageName).into(imageView);
...
Run Code Online (Sandbox Code Playgroud)
如何在ImageView中显示图像,但imagePath总是为空?:) 谢谢
编辑:
我如何将图像发送到服务器
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost …Run Code Online (Sandbox Code Playgroud)