Java 为什么我的if语句的条件是;if(requestCode==CropImage.CROP“图像”活动“请求”代码)";总是假的?

Java 为什么我的if语句的条件是;if(requestCode==CropImage.CROP“图像”活动“请求”代码)";总是假的?,java,if-statement,permissions,Java,If Statement,Permissions,我一直在学习如何选择图片、裁剪图片并上传到我的应用程序。。。它选择,它作物,但它上传了未修剪的图片…我没有看到任何错误 有: @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == REQUEST_WRITE_PERMISSION && grantResul

我一直在学习如何选择图片、裁剪图片并上传到我的应用程序。。。它选择,它作物,但它上传了未修剪的图片…我没有看到任何错误

有:

@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        if (requestCode == REQUEST_WRITE_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            //THIS IS HAPPEN WHEN USER CLICK ALLOW ON PERMISSION
            //START PICK IMAGE ACTIVITY
            CropImage.startPickImageActivity(addceleb.this);
        }
    }
这将启动以下功能:

@Override
    @SuppressLint("NewApi")
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
            Uri imageUri = CropImage.getPickImageResultUri(this, data);
            Log.i("RESPONSE getPath", imageUri.getPath());
            Log.i("RESPONSE getScheme", imageUri.getScheme());
            Log.i("RESPONSE PathSegments", imageUri.getPathSegments().toString());
            //GET IMAGEVIEW RESULT URI AND PASS TO IMAGEVIEW
            imageView.setImageURI(imageUri);

            //NOW CROP IMAGE URI
            CropImage.activity(imageUri)
                    .setGuidelines(CropImageView.Guidelines.ON)
                    .setMultiTouchEnabled(true)
                    .setRequestedSize(800, 800)
                    .setAspectRatio(1,1)
                    .start(this);

            if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
                CropImage.ActivityResult result = CropImage.getActivityResult(data);
                if (resultCode == RESULT_OK) {
                    Log.i("RESPONSE getUri", result.getUri().toString());
                    //GET CROPPED IMAGE URI AND PASS TO IMAGEVIEW
                    imageView.setImageURI(result.getUri());
                }
            }
        }
将显示以下建议:


Condition 'requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE' is always 'false' less... (Ctrl+F1) 
Inspection info: This inspection analyzes method control and data flow to report possible conditions that are always true or false, expressions whose value is statically proven to be constant, and situations that can lead to nullability contract violations.
Variables, method parameters and return values marked as @Nullable or @NotNull are treated as nullable (or not-null, respectively) and used during the analysis to check nullability contracts, e.g. report NullPointerException (NPE) errors that might be produced.
More complex contracts can be defined using @Contract annotation, for example:
@Contract("_, null -> null") — method returns null if its second argument is null @Contract("_, null -> null; _, !null -> !null") — method returns null if its second argument is null and not-null otherwise @Contract("true -> fail") — a typical assertFalse method which throws an exception if true is passed to it 
The inspection can be configured to use custom @Nullable
@NotNull annotations (by default the ones from annotations.jar will be used)

这是一个条件:

if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE /* && ... */) {
  // ...
  if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
    // ...
  }
}
除非
PICK\u IMAGE\u CHOOSER\u REQUEST\u code==CROP\u IMAGE\u ACTIVITY\u REQUEST\u code
,否则后面的条件将为false