java应用程序从外部存储中拾取图像时崩溃

11dmarpk  于 2021-07-05  发布在  Java
关注(0)|答案(2)|浏览(352)

我的onactivityresult代码

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GalleryPick && resultCode == RESULT_OK && data!= null) {
        Uri imageUri = data.getData();

        CropImage.activity()
                .setGuidelines(CropImageView.Guidelines.ON)
                .setAspectRatio(1,1)
                .start(SettingsActivity.this);
    }

    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            Uri resultUri = result.getUri();
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
        }
    }
}

当我尝试从设备库中选取图像时,它会在图像裁剪活动中崩溃告诉我代码有什么问题
错误是

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/25/ORIGINAL/NONE/1270245750 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F25/ORIGINAL/NONE/1270245750} }} to activity {com.gihan.mechat/com.gihan.mechat.SettingsActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.gihan.mechat/com.theartofdev.edmodo.cropper.CropImageActivity}; have you declared this activity in your AndroidManifest.xml?

应用程序崩溃

start(SettingsActivity.this);

`

eqqqjvef

eqqqjvef1#

这个错误告诉你为什么会这样 have you declared this activity in your AndroidManifest.xml? 有你?

s3fp2yjn

s3fp2yjn2#

检查权限,我有一次这样的问题,对于api>29,我们需要在清单文件下面的代码。

android: requestLegacyExternalStorage = true

此代码是获取存储权限所必需的。此外,请转到手机中的权限管理器设置,然后选中此处的切换按钮。

相关问题