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);

 }

你可能感兴趣的:(android,相册)