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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:25:46+00:00 2026-05-26T08:25:46+00:00

my onActivityResult method is never called. am using android 2.2 I am using a

  • 0

my onActivityResult method is never called. am using android 2.2

I am using a Tabhost, where TabHosts contain TabGroups which contain individual Activities.

One of my individual activity runs the following intent

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

this loads my gallery apps, I use the default android gallery to select one image and when I return my onActivityResult is not called my activity.

It looks like this – and I put a breakpoint at if(resultCode == 0) , so right now, the logic of my onActivityResult should not matter

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == 0) {
        if (requestCode == 0) {
            Uri selectedImageUri = data.getData();

            //OI FILE Manager
            filemanagerstring = selectedImageUri.getPath();

            //MEDIA GALLERY
            selectedImagePath = getPath(selectedImageUri);

            //DEBUG PURPOSE - you can delete this if you want
            if(selectedImagePath!=null)
                System.out.println(selectedImagePath);
            else System.out.println("selectedImagePath is null");
            if(filemanagerstring!=null)
                System.out.println(filemanagerstring);
            else System.out.println("filemanagerstring is null");

            //NOW WE HAVE OUR WANTED STRING
            if(selectedImagePath!=null)
                System.out.println("selectedImagePath is the right one for you!");
            else
                System.out.println("filemanagerstring is the right one for you!");
        }
    }
}

Lifecycle functions are often called out of order and intermittently for Activities within a tabhost/tabgroup, so I checked to see what lifecycle functions ARE being called after the gallery closes (this happens as soon as I select an image from the android gallery)

The only one being called is the onResume() in my TabHost activity. So I tried putting the exact same onActivityResult() method in my TabHost class AS WELL AS the TabActivity class. With a breakpoint in the same location at the beginning of method.

Neither of these classes are called.

I’m drawing a blank now, how can I get the result from the gallery app in my app if none of the built in receiving methods will respond to it.

Since I know that my main TabHost gets the onResume() called, I tried added Intent graphics = getIntent(); to see if it would receive data from the gallery selection, it does not, so I don’t see how I can do the logic in the onResume() method either.

Solutions welcome! 🙂

  • 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-05-26T08:25:47+00:00Added an answer on May 26, 2026 at 8:25 am

    The solution is to call a transparent activity over top of the main activity. This transparent activity is in front of the tabhost and will have normal lifecycle functions.

    This transparent activity calls the gallery intent onCreate(), it gets everything returned like normal in its onActivityResult and you will be able to pass the information returned back to the rest of the app like normal. finish() is inside of the onActivityResult method, so the user never even notices that a transparent activity was called.

    Update copied from from comments:

    Activity A calls Activity B via normal intent. Activity B has no xml and runs onCreate like this

    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        //setContentView(R.layout.dialogpopper); 
    
        Intent intent = new Intent(Intent.ACTION_PICK); 
        intent.setType("image/*"); startActivityForResult(intent, 0);
    
    }//end onCreate 
    

    and when Activity C is finished it calls the onActivityResult of Activity B

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

Sidebar

Related Questions

i have a main Activity called Main which has onActivityResult Method. protected void onActivityResult(int
In Activity lifecycle the onActivityResult method is called before the onCreate methode, where all
I'm having a problem with the onActivityResult() method not being called. I suspect this
Could someone tell me which gets called first, is it onActivityResult() or is it
I implement a project which contain a activity group mainActivity. This main activity contains
I start an IMAGE_CAPTURE Intent like this, and my activity's onActivityResult() get called: Intent
I have an android.net.URI object (of the kind returned by onActivityResult after MediaStore.ACTION_VIDEO_CAPTURE): it
I have two activities: a MainListActivity, and a DetailViewActivity. DetailViewActivity is set with android:launchMode=singleTop
I have 2 activities. In child activity i have put something like that in
I'm trying to take a picture from the Camera using intent with onActivityResult but

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.