拍照后,获取图像的URI onActivityResult?图像、URI、onActivityResult

2023-09-06 02:28:10 作者:别来无恙你还狗样

我有这个code:

  startActivityForResult(新意图(MediaStore.ACTION_IM​​AGE_CAPTURE),CAMERA_IMAGE);
 

,它允许用户拍摄照片。现在,我怎么会得到 onActivityResult 的那张照片乌里?它是一个意图额外?它是通过 Intent.getData()

解决方案

 保护无效onActivityResult(INT申请code,INT结果code,意图意图){
    乌里U = intent.getData();
}
 

顺便说一句...有与意图在某些设备上的错误。看看这个答案要懂得变通办法。

色彩范围抠图法,你会吗

I have this code:

startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), CAMERA_IMAGE);

That allows that user to take a photo. Now how would I get the Uri of that photo in onActivityResult? Is it an Intent extra? Is it through Intent.getData()?

解决方案

protected void onActivityResult(int requestCode, int resultCode, Intent intent){
    Uri u = intent.getData();
}

By the way... there's a bug with that intent in some devices. Take a look at this answer to know how to workaround it.