Intent intent = new Intent();
/* 开启Pictures画面Type设定为image */
intent.setType( "image/*");
//intent.setType( "audio/*"); //选择音频
//intent.setType( "video/*"); //选择视频 (mp4 3gp 是android支持的视频格式)


/* 使用Intent.ACTION_GET_CONTENT这个Action */
intent.setAction(Intent.ACTION_GET_CONTENT);
/* 取得相片后返回本画面 */
startActivityForResult(intent, 1);

 


Intent intent = new Intent("com.android.camera.action.CROP");
  intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
  intent.putExtra("crop", "true");
  // aspectX aspectY 是宽高的比例
  intent.putExtra("aspectX", 1);
  intent.putExtra("aspectY", 1);
  // outputX outputY 是裁剪图片宽高
  intent.putExtra("outputX", 350);
  intent.putExtra("outputY", 350);
  intent.putExtra("return-data", true);// 返回值中有图片数据
  startActivityForResult(intent, PHOTORESOULT);

发现如果裁剪的图片过大 startActivityForResult(intent, PHOTORESOULT);就会不起作用,自己猜测是图片过大系统处理过了

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-04-19
  • 2021-12-01
  • 2021-12-04
  • 2021-12-29
  • 2021-12-12
猜你喜欢
  • 2021-07-20
  • 2021-07-31
  • 2022-01-09
  • 2022-12-23
  • 2021-08-08
  • 2022-02-04
  • 2021-12-17
相关资源
相似解决方案