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

The Archive Base Latest Questions

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

I have a TabHost and in that 4 different Activities. In first Tab i

  • 0

I have a TabHost and in that 4 different Activities. In first Tab i have a option to select image from gallery or take photo from camera. Now, i used public void onActivityResult(int requestCode, int resultcode, Intent intent) method..but, it is not being called in TabHost..Without tabHost it is working perfectly…How to solve this..Here is my code..Please check my whole code..Thanks in Advance..

tblTreePhoto.setOnClickListener(new OnClickListener() 
        {

            @Override
            public void onClick(View arg0) 
            {
                final AlertDialog.Builder alertDialog = new AlertDialog.Builder(getParent());
                alertDialog.setTitle("Select Photo");
                alertDialog.setPositiveButton("Take Photo", new DialogInterface.OnClickListener() 
                {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) 
                    {
                        if(Tree_Image.count<3)
                        {
                            Intent i1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                            File out = Environment.getExternalStorageDirectory();
                            out = new File(out, "newImage.jpg");
                            i1.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out));
                            getParent().startActivityForResult(i1, 10); 
                        }
                        else
                        {
                            Toast.makeText(getApplicationContext(), "You can not add more than 2 photos" , 1).show();
                        }
                    }

                });

                alertDialog.setNeutralButton("Gallery", new DialogInterface.OnClickListener() 
                {

                    @Override
                    public void onClick(DialogInterface dialog, int which) 
                    {   
                        if(Tree_Image.count<3)
                        {
                            Intent intent = new Intent();
                            intent.setType("image/*");
                            intent.setAction(Intent.ACTION_GET_CONTENT);
                            getParent().startActivityForResult(Intent.createChooser(intent,"Select Picture"),1);
                        }   
                        else
                        {
                            Toast.makeText(getApplicationContext(), "You can not add more than 2 photos" , 1).show();

                        }
                    }
                });
                alertDialog.setNegativeButton("View Selected Photos", new DialogInterface.OnClickListener() 
                {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) 
                    {
                        Intent i = new Intent(getParent(),Show_Selected_Images.class);
                        //i.putExtra("cqname", client_name.getText().toString());
                        startActivity(i);
                    }

                });

                alertDialog.show();

            }
        });

and this is my onActivityResult Method:-

 protected void onActivityResult(int requestCode, int resultcode, Intent intent)
     {
         int orientation =0;
         Log.d("result ","code uis"+resultcode);

         super.onActivityResult(requestCode, resultcode, intent);

         if (requestCode == 1)
         {
             if (intent != null && resultcode == RESULT_OK)
             {             

                 Uri selectedImage = intent.getData();

                   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);
                   Log.v("log","filePath is : "+filePath);

                   cursor.close();
                   try 
                   {
                        ExifInterface exif = new ExifInterface(filePath);
                         orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
                        //Toast.makeText(getApplicationContext(), ""+orientation, 1).show();
                        Log.v("log", "ort is "+orientation);

                   } 
                   catch (IOException e)
                   {
                       e.printStackTrace();
                   }

                   if(bmp != null && !bmp.isRecycled())
                   {
                       bmp = null;               
                   }

                   File f = new File(filePath);
                   bmp = decodeFile(f,400,400);

                   if (orientation==6)
                   {
                        Matrix matrix = new Matrix();
                        matrix.postRotate(90);
                        bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
                   }
                   else if (orientation==8)
                   {
                        Matrix matrix = new Matrix();
                        matrix.postRotate(270);
                        bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
                   }

                   else if (orientation==3)
                   {
                        Matrix matrix = new Matrix();
                        matrix.postRotate(180);
                        bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
                   }

                   Log.v("log", "before width is "+bmp.getWidth() + " and height is "+bmp.getHeight());

                   bt=Bitmap.createScaledBitmap(bmp,320, 300, false);
                  // Bitmap bt_thumb = Bitmap.createScaledBitmap(bmp, 70, 70, false);




                   Intent i = new Intent(Tree_Assessmnt_Tree.this,Tree_Image.class);
                   i.putExtra("userid", uid);
                  // TabGroupActivity parentActivity = (TabGroupActivity) getParent();
                   startActivity(i);

             }
             else
             {
                 Log.v("log", "Photopicker canceled");           
             }
         }
         else if (requestCode == 10)
         {

           File out = new File(Environment.getExternalStorageDirectory(), "newImage.jpg");

             if(!out.exists())
             {
                 Log.v("log", "file not found");
                 Toast.makeText(getBaseContext(),"Error while capturing image", Toast.LENGTH_LONG).show();

                return;

            }

             Log.v("log", "file "+out.getAbsolutePath());
             File f = new File(out.getAbsolutePath());

             try
             {

                ExifInterface exif = new ExifInterface(out.getAbsolutePath());
                 orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
                //Toast.makeText(getApplicationContext(), ""+orientation, 1).show();
                Log.v("log", "ort is "+orientation);

           } 
             catch (IOException e)
             {
                 e.printStackTrace();
             }

             Bitmap photo =decodeFile(f,400,400);
             if (orientation==6)
             {
                    Matrix matrix = new Matrix();
                    matrix.postRotate(90);
                    photo = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight(), matrix, true);
             }
             else if (orientation==8)
             {
                    Matrix matrix = new Matrix();
                    matrix.postRotate(270);
                    photo = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight(), matrix, true);
             }

             else if (orientation==3)
             {
                    Matrix matrix = new Matrix();
                    matrix.postRotate(180);
                    photo = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight(), matrix, true);
             }



           //Bitmap photo = (Bitmap) intent.getExtras().get("data"); 
           //bt=Bitmap.createScaledBitmap(photo, 380, 520, false);
           bt=photo;
          // bt=Bitmap.createScaledBitmap(photo,320, 300, false);
//         Log.v("log", "before width is "+bt.getWidth() + " and height is "+bt.getHeight());

                /*  gamePic.setBackgroundResource(0);
                  gamePic.setImageBitmap(photo);*/
           //txtPhoto.setText(""+DrawOnImage_Activity.count);


           Intent i = new Intent(Tree_Assessmnt_Tree.this,Tree_Image.class);
           i.putExtra("userid", uid);
           startActivity(i);

         }

         else if(requestCode==6)
         {
              if (intent == null)
              {
                  Log.v("log", "Null data, but RESULT_OK, from image picker!");
                       Toast t = Toast.makeText(this, "No Photo Slected",Toast.LENGTH_SHORT);
                       t.show();

                       return;
              }
         }
     }
  • 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-14T02:00:50+00:00Added an answer on June 14, 2026 at 2:00 am

    Other way of doing is this.

    1. On button click(which you want to open intent) open another activity.
    2. On another activity’s onCreate() open that intent.
    3. onActivityResult set static data which is on previous activity and call finish().
    4. This way no one ever know that you opened such a activity and you ll get your data.

    🙂

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

Sidebar

Related Questions

I have a TabHost activity that are switching activities, so my main looks like
Using this sample : I have make my own Fragment that holds tabhost and
I have a Fragment that has contains lots of info (article) with a tabhost
I have a Tabhost which is my main activity. When a tab is clicked
I have a tabhost with two tabs. Each tab has his own activity. My
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have an Android application with a main activity that is the tabhost. I'm
I have an Android application that is a TabHost with a WebView. I use
I have an app that uses a TabHost. Several of the Tabs share a

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.