batuman
batuman

Reputation: 7304

startActivityForResult() for CameraActivity return -1 on success

I can't find clear result in my search, that is why I raise this query. I activate camera activity using startActivityForResult(cameraIntent, CAMERA_REQUEST);. On return to the onActivityResult, resultCode is -1 on success and resultCode becomes 0 if I press back button. Normally -1 stands for failure and 0 should be for success case. Is that normal? Or where I need to change for returning 0 on success. My code is as follow.

    public void imagepos(int i){
       //onImage click comes here
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
        startActivityForResult(cameraIntent, CAMERA_REQUEST);
        imagePosition = i;

    }



    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
          super.onActivityResult(requestCode, resultCode, data);
          Bitmap scaledBitmap  = null;
          if (requestCode == CAMERA_REQUEST && resultCode != RESULT_OK) {  

          }  

    }

Upvotes: 0

Views: 262

Answers (1)

Cob013
Cob013

Reputation: 1067

public static final int RESULT_OK Added in API level 1

Standard activity result: operation succeeded. Constant Value: -1 (0xffffffff)

From: RESULT_OK

You're relating to POSIX like standard where -1 (or eventually 0) are for not-successfull return values. Here in Android you just need to use already-defined constants and everything will go as desired.

(I've hit my head to the closest wall after half an hour of unsuccessful debugging while I was checking return code with '1' so I feel your question :P)

Upvotes: 1

Related Questions