Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:49:30+00:00 2026-06-05T02:49:30+00:00

hi i am not able to getting call to method onActivityResult after below code.

  • 0

hi i am not able to getting call to method onActivityResult after below code.

private void ImageChooseOptionDialog() {

    Log.i(TAG, "Inside ImageChooseOptionDialog");
    String[] photooptionarray = new String[] { "Take a photo",
            "Choose Existing Photo" };

    Builder alertDialog = new AlertDialog.Builder(TabSample.tabcontext)
            .setItems(photooptionarray,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {
                            if (which == 0) {
                                Log.i(TAG, "Which" + which);
                                Log.i(TAG,
                                        "Inside ImageChooseOptionDialog Camera");
                                _path = Environment
                                        .getExternalStorageDirectory()
                                        + File.separator
                                        + "TakenFromCamera.png";

                                Log.d(TAG, "----- path ----- " + _path);
                                media = _path;
                                // File file = new File(_path);
                                // Uri outputFileUri = Uri.fromFile(file);
                                // Intent intent = new Intent(
                                // android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                                // intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                // outputFileUri);
                                // startActivityForResult(intent, 1212);

                            } else if (which == 1) {
                                Log.i(TAG, "Which" + which);
                                Log.i(TAG,
                                        "Inside ImageChooseOptionDialog Gallary");
                                // Intent intent = new Intent();
                                // intent.setType("image/*");
                                // intent.setAction(Intent.ACTION_GET_CONTENT);
                                // startActivityForResult(Intent
                                // .createChooser(intent,
                                // "Select Picture"), 1);

                                Intent intent = new Intent(
                                        Intent.ACTION_GET_CONTENT);
                                intent.setType("image/*");
                                // intent.setAction(Intent.ACTION_GET_CONTENT);
                                startActivityForResult(Intent
                                        .createChooser(intent,
                                                "Select Picture"), 1);

                                Log.i(TAG, "end" + which);

                            }
                        }
                    });
    alertDialog.setNeutralButton("Cancel",
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.create().show();
}

and this is my onActivityResult method:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(TAG, "Inside Onactivity Result");
    if (resultCode == RESULT_OK) {
        if (requestCode == 1) {
            Log.i(TAG, "Inside if else Onactivity Result");
            // currImageURI is the global variable I’m using to hold the
            // content:// URI of the image
            Uri currImageURI = data.getData();
            String path = getRealPathFromURI(currImageURI);
            Log.i(TAG, "Inside Onactivity Result Image path" + path);

        }
    }
}

please let me knew where i am doing wrong. i am calling onActivityResult method from which=1 after dialog box appears.
but not getting any log inside onActivityResult method in logcat.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:49:33+00:00Added an answer on June 5, 2026 at 2:49 am

    This is because, you may not be getting RESULT_OK. Always first check for request code and inside that check for result code. If you are retrieving image from gallery, try following code inside onActivityResult():

    if (requestCode == TAKE_PICTURE_GALLERY) {
                if (resultCode == RESULT_OK) {
    
                    final Uri selectedImage = data.getData();
                    final String[] filePathColumn = { MediaStore.Images.Media.DATA };
    
                    final Cursor cursor = getContentResolver().query(selectedImage,
                            filePathColumn, null, null, null);
                    cursor.moveToFirst();
    
                    final int columnIndex = cursor
                            .getColumnIndex(filePathColumn[0]);
                    final String filePath = cursor.getString(columnIndex);
                    cursor.close();
                 }
    }
    

    And use the filePath wherever you want.
    I hope this solves your problem. Thank you 🙂

    UPDATE:
    Use this code to start your gallery activity:

     imagePathURI = Uri.fromFile(new File(<your image path>));
            final Intent intent = new Intent(Intent.ACTION_PICK, imagePathURI);
                    intent.setType("image/*");
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, imagePathURI);
                    startActivityForResult(intent, TAKE_PICTURE_GALLERY);
    

    When you want to retrieve image from gallery, the MediaStore.EXTRA_OUTPUT refers to The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video. So here, you have to pass the image path where u’ll receive your image.
    imagePathURI = Uri.fromFile(new File(<your image path>)); // here a file will be created from your image path. And when you’ll receive an image, u can access the image from this image path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an error with FlexUnit 4 that I am not able to find
I'm getting an exception from Cruise Control about not being able to connect to
I am still not able to make phone call using previous answer. I am
I am getting the following error: Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() The
Im not able to load the page with circlepageindicator. This is the xml <FrameLayout
I am not able to flush stdin here, is there a way to flush
I am not able to make a clear decision on this one. I am
I am not able to get my jwysiwyg and Jhtmlarea text editors to work
I am not able to figure out why it is not tracing value for
I'm not able to connect a simple client and a simple server. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.