Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid onActivityResult NEVER called
    text
    copied!<p>my onActivityResult method is never called. am using android 2.2</p> <p>I am using a Tabhost, where TabHosts contain TabGroups which contain individual Activities.</p> <p>One of my individual activity runs the following intent</p> <pre><code> Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 0); </code></pre> <p>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.</p> <p>It looks like this - and I put a breakpoint at <code>if(resultCode == 0)</code> , so right now, the logic of my onActivityResult should not matter</p> <pre><code> 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!"); } } } </code></pre> <p>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)</p> <p>The only one being called is the <code>onResume()</code> in my TabHost activity. So I tried putting the exact same <code>onActivityResult()</code> method in my TabHost class AS WELL AS the TabActivity class. With a breakpoint in the same location at the beginning of method.</p> <p>Neither of these classes are called.</p> <p>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.</p> <p>Since I know that my main TabHost gets the <code>onResume()</code> called, I tried added <code>Intent graphics = getIntent();</code> 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.</p> <p>Solutions welcome! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload