切换案例在android中的onActivityResult中给出奇怪的响应

Rah*_*pil -3 java android break switch-statement android-activity

我有活动,我正在打开相机,语音和视频的意图.我正在使用onActivityResult.但是当onActivityResult被调用时,我正在观察一些非常奇怪的事情,在所有情况下,所有情况下被调用意味着它的gng.

怎么可能.我错了什么?.

以下是我的代码

   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
            }

        }


    }






}
Run Code Online (Sandbox Code Playgroud)

G M*_*esh 12

break;在每个案例结束时添加并检查

switch(requestCode) { 
   case 1:
    //code
    break;
   case 2:
    //code
   break;
   .
   .
   default:

   break;
}
Run Code Online (Sandbox Code Playgroud)