intent = new Intent(Intent.ACTION_PICK);// intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); // 开启一个带有返回值的Activity,请求码为PHOTO_REQUEST_GALLERY// intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, 1);
android调用图库时,回传获得的uri.getpath().得到的路径,为文档路径,不是手机上的绝对路径。通过
String [] proj={MediaStore.Images.Media.DATA}; String imagePath=""; Cursor cursor=managedQuery(uri, proj,//查哪一列 null,null,null); if(cursor!=null) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if( cursor.getCount()>0 && cursor.moveToFirst() ) { imagePath = cursor.getString(column_index); MLog.e("absolutaly-path",imagePath+""); MLog.e("uri path",uri.getPath()); } }

被折叠的 条评论
为什么被折叠?



