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 8627209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:13:10+00:00 2026-06-12T08:13:10+00:00

I have Activity within which i am opening intents for camera ,voice and video

  • 0

I have Activity within which i am opening intents for camera ,voice and video .i am using onActivityResult for it . But when onActivityResult is getting called i am observing something very strange all the case within switch case are getting called means its gng in all the cases .

How it is possible .Am i dpong something wrong? .

Below is my code

   protected void onActivityResult(int requestCode, int resultCode, Intent data) 
     {
      super.onActivityResult(requestCode, resultCode, data); 

       if(resultCode == RESULT_OK){




          switch(requestCode) { 

             case 1:

                Uri selectedImage = data.getData();
                System.out.println("selectedimage"+selectedImage);
                String[] filePathColumn = {MediaStore.Images.Media.DATA};

                Cursor cursor = getContentResolver().query(selectedImage,       filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String filePath = cursor.getString(columnIndex);
                cursor.close();


                yourSelectedImage = BitmapFactory.decodeFile(filePath);
                /* Now you have choosen image in Bitmap format in object "yourSelectedImage". You can use it in
                 *  way you want! */



                btn_img.setImageBitmap(yourSelectedImage);





        case 0:
            try {
                yourSelectedImage = (Bitmap) data.getExtras().get("data");
                btn_img.setImageBitmap(yourSelectedImage);
                System.out.println("try for 0"+yourSelectedImage);
            } catch (Exception e) {
                // TODO: handle exception
            }

        case 2:
            try {


                    System.out.println("ooookkkkkk");


                        System.out.println("SELECT_AUDIO");
                        Uri selectedImageUri = data.getData();
                        selectedPath = getPath(selectedImageUri);
                        try {
                            System.out.println("try for 2"+yourSelectedImage);
                             btn_img.setImageBitmap(yourSelectedImage);
                        } catch (Exception e) {
                            System.out.println("catch"+yourSelectedImage);
                            // TODO: handle exception
                        }
                        System.out.println("SELECT_AUDIO Path : " + selectedPath);
                       // doFileUpload();





            } catch (Exception e) {
                // TODO: handle exception
            }

        case 3:
            try {




                        System.out.println("SELECT_AUDIO");
                        Uri selectedImageUri = data.getData();
                        selectedPath = getPath(selectedImageUri);
                        try {
                            System.out.println("try for 3"+yourSelectedImage);
                             btn_img.setImageBitmap(yourSelectedImage);
                        } catch (Exception e) {
                            System.out.println("catch"+yourSelectedImage);
                            // TODO: handle exception
                        }
                        System.out.println("SELECT_AUDIO Path : " + selectedPath);
                       // doFileUpload();




            } catch (Exception e) {
                // TODO: handle exception
            }

        }


    }






}
  • 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-12T08:13:12+00:00Added an answer on June 12, 2026 at 8:13 am

    Add break; at the end of every cases and check

    switch(requestCode) { 
       case 1:
        //code
        break;
       case 2:
        //code
       break;
       .
       .
       default:
    
       break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which is displaying a web page using a WebView. Within
I have an activity which loads a data list from the server using loader
I have an class Voice , which extends Activity , and contains a counter.
I am using an ActivityGroup to open up Activity 2 from within Activity1, which
Within one Activity I have th following piece of code: public void onStartMonitoringToggleClicked(View v)
I have implemented a custom view within another activity into a XML layout. The
I have an broadcast-receiver that looks like the following within an activity named childActivity
I am having trouble with my activity management. So I have activity A which
I have an Activity A that calls an Activity B using startActivityForResult() . Under
I have an activity. In this activity I want to start another activity using

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.