@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
/** 调用原生文件管理器,根据返回选择的文件,来进行操作 **/
if (resultCode == Activity.RESULT_OK) {
// Get the Uri of the selected file
Uri uri = data.getData();
textShow.setText(getAbsoluteImagePath(uri));
certUrl.setText(getAbsoluteImagePath(uri));
//Uri获取真实路径转换成File的方法
protected String getAbsoluteImagePath(Uri uri)
{
// can post image
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery( uri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
/** 调用原生文件管理器,根据返回选择的文件,来进行操作 **/
if (resultCode == Activity.RESULT_OK) {
// Get the Uri of the selected file
Uri uri = data.getData();
textShow.setText(getAbsoluteImagePath(uri));
certUrl.setText(getAbsoluteImagePath(uri));
}
//Uri获取真实路径转换成File的方法
protected String getAbsoluteImagePath(Uri uri)
{
// can post image
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery( uri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}