Android中调用相册里面的图片并返回:
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true);
startActivityForResult(intent, 0);
在原来的Activity中如下获取选到的图片:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println(resultCode);
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("data");
super.onActivityResult(requestCode, resultCode, data);
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true);
startActivityForResult(intent, 0);
在原来的Activity中如下获取选到的图片:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println(resultCode);
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("data");
super.onActivityResult(requestCode, resultCode, data);
}
本文转自HDDevTeam 51CTO博客,原文链接:http://blog.51cto.com/hddev/1218419,如需转载请自行联系原作者