The result of the operation is always 0

I am looking all day for this problem:

mUploadImage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");

            startActivityForResult(
                    Intent.createChooser(intent, "Select a Picture"),
                    FILE_SELECT_CODE);
        }
    });

Whenever I click on the mUploadImage OnActivityResult () method, it starts immediately (although I still don’t select any file), and the result code is always 0. Can someone help me?

EDIT: (from the comment below)

protected void onActivityResult(int arg0, int arg1, Intent arg2) {
    if (arg0 == FILE_SELECT_CODE) {
        Log.v(TAG, "Selected a image. Result code: " + arg1);
        if (arg1 == Activity.RESULT_OK) {
+1
source share
1 answer

Check out these answers. They all say that there is a relationship between the launchMode function and the reporting result immediately

onActivityResult () called prematurely

Android - startActivityForResult immediately launches onActivityResult

onActivityResult () is called at unexpected time

+2
source

All Articles