Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 片段在从camera onActivityResult获得结果后重新加载_Android_Camera_Fragment_Onactivityresult - Fatal编程技术网

Android 片段在从camera onActivityResult获得结果后重新加载

Android 片段在从camera onActivityResult获得结果后重新加载,android,camera,fragment,onactivityresult,Android,Camera,Fragment,Onactivityresult,在5.1版本中使用Micromax Q424时,Android片段在从select camera或gallery onActivityResult获得结果后被重新加载。在其他手机中,但在Micromax Q424中,片段被重新加载。获取结果后如何避免。您好您是否已授予使用相机所需的权限,运行时权限以及清单权限也是必需的 public boolean CheckPermissionForWriteStorage() { if (Build.VERSION.SDK_INT >=

在5.1版本中使用Micromax Q424时,Android片段在从select camera或gallery onActivityResult获得结果后被重新加载。在其他手机中,但在Micromax Q424中,片段被重新加载。获取结果后如何避免。

您好您是否已授予使用相机所需的权限,运行时权限以及清单权限也是必需的

public boolean CheckPermissionForWriteStorage() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
                checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

            requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    PERMISSIONS_REQUEST_CODE_WRITE_EXTERNAL_STORAGE);

            return false;
        }

        return true;
    }
使用上述代码获取许可 下面是onACtivityResult中的代码

 final boolean isCamera;
                if (data == null) {
                    isCamera = true;
                } else {
                    final String action = data.getAction();
                    if (action == null) {
                        isCamera = false;
                    } else {
                        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                            isCamera = true;
                        } else {
                            isCamera = action.equalsIgnoreCase(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                        }
                    }
                }

                if (isCamera) {
                    String selectedImagePath = getImagePath();

                    aQuery.id(imgFarmerPhoto).image(selectedImagePath);
                } else {
                    String selectedImagePath = getAbsolutePath(data.getData());
                    selectedImagePath = getRightAngleImage(selectedImagePath);
                    aQuery.id(imgFarmerPhoto).image(selectedImagePath);
                }