标签:
/************打开相册*********/
private int ABLUM = 1313;
public void OpenAblum(){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image");
startActivityForResult(intent,ABLUM);
}
/*****回调函数***/
public void onActivityResult(int reqcode,int respcode,Intent data){
super(reqcode,respcode,data);
if(reqcode == ABLUM){
Uri uri = data.getData();
String path = getPath(uri,MainActivity.this);/***图片的地址***/
}
}
/***获取路径********/
public String getPath(Uri uri,Activity activity){
String[] projection = {MediaStore.Images.Media.DATA}‘;
Cursor cursor = activity.manageQuery(uri,projection,null,null,null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);;
cursor.moveToFirst();
String path = cursor.getString(column_index);
retrun path;
}
标签:
原文地址:http://www.cnblogs.com/mjjy/p/4963208.html