When the Activity uses startActivityForResult, The onActivityResult () is not executed. startactivity

Source: Internet
Author: User

When the Activity uses startActivityForResult, The onActivityResult () is not executed. startactivity

You can use startActivityForResult () and onActivityResult () Methods to pass or receive parameters between activities.
However, sometimes we encounter onActivityResult () not executed,

The first case is that the onActivityResult () method is also executed when startActivityForResult is executed. When we press log, we will find it in the onActivityResult () method.
The resultCode parameter always returns 0. This is related to the Activity loading mode, that is, when activity is set in AndroidManifest. xml
Android: launchMode indicates that onActivityResult () is invalid when Activity is set to singleton mode in android SDK, that is, android: launchMode = "singleTask"
And android: launchMode = "singleInstance" will cause invalid

The second case is startActivityForResult (intent, 0); the second parameter in this method. When we set this parameter to less than 0, we will find that the onActivityResult () method has no response.
Android SDK mentioned that this parameter must be greater than or equal to 0.

 

In the third case, when startActivityForResult in the TabHost sub-Activity calls other activities, the onActivityResult method does not respond. Let's look at the following link.

 

Http://www.cnblogs.com/relinson/archive/2012/03/25/startActivityForResult.html


OnActivityResult () in startactivityforresult is not executed

Have you used ActivityGroup? I can't execute it when ActivityGroup is used. Let's talk about the specific situation.
 
Ask startActivityForResult onActivityResult

It can be solved. In the onActivityResult method, the returned results can be captured. Because A and Activity are put in tabhost, the returned results are not captured in A, but captured in tabhost, so you can capture it in tabhost and pass it to Activity.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.