gpt4 book ai didi

android - resultCode == RESULT_OK 在 redmi note3 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 13:47:35 25 4
gpt4 key购买 nike

您好,我想在我的下一个 Activity 中捕捉图像并对该图像做一些操作。我尝试在三星和 Moto G 中运行以下代码并且它工作正常。当我在 redmi note3 上尝试相同的代码时,点击后正确标记它正在参加同一 Activity 。如何解决这个问题?这是我的代码:

 fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri outputFileUri = Uri.fromFile(originalFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), "No camera app found!", Toast.LENGTH_LONG).show();
}

}
});

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
Bitmap imageData = null;
if (resultCode ==Activity.RESULT_OK) {
try
{
BitmapFactory.Options bitopt=new BitmapFactory.Options();
imageData = BitmapFactory.decodeFile(imagePath, bitopt);
Uri tempUri = getImageUri(getApplicationContext(), imageData);

Intent i = new Intent(this, Image_R.class);
i.putExtra("imageUri", tempUri.toString());
startActivityForResult(i, 3);
}
catch (Exception e) {
Toast.makeText(this, "Unable to save image", Toast.LENGTH_LONG).show();
}

} else if (resultCode == RESULT_CANCELED) {
// User cancelled the image capture
}
}

最佳答案

替换这个:--

i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContentProvider.CONTENT_URI);

关于android - resultCode == RESULT_OK 在 redmi note3 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39482550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com