Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//相册选择图片的intent
选择图片后我希望能把图片给File量mPhotoFile
然后再调用一个intent,并用putExtra("photo",mPhotoFile);
的方式传给另一个class
如何将从相册提出的照片赋给file量呢?
一般传的是图片路径,因为如果是传图片数据量比较大,可能会发生ANR。目标Activity取得图片路径后 这样就可以得到Bitmap对象:Bitmap bitmap = BitmapFactory.decodeFile(url_path); 其中,url_path是原activity传过来的图片路径
在跳转相册的onActivityResult()里面生成图片或者获取图片路径,判断不为空再Intent intent = new Intent(当前Activity,跳转后Activity); intent.putExtra("photo",值),startActivity(intent);这样应该就好了