Android-Fragment's onActivity strange Bug

Source: Internet
Author: User

Android-Fragment's onActivity strange Bug

1. You will often see the nested Fragment of the Activity, and open another Activity from Fragment,

When the onActivityResult () method of Activity and Fragment is rewritten, it is found that the onActivityResult () method of the Fragment is not executed,

The onActivityResult () method for executing the Activity. The reason is that the method for opening another Activity is incorrect.

In the Activity, activity. startActivityForResult (intent, requestCode );

In Fragment, f. startActivityForResult (intent, requestCode) is also available );

That is to say, the onActivityResult () of the person who opens the message is called ();


2. Recently, we made an image retrieval function in Fragment, that is, enabling the image retrieval function of the system to retrieve the selected image.

But this function is in the Fragment of the main Activity, because we often change the loading mode of the main Activity to SingleInstance,

In Fragment, onActivityResult () is executed when the Activity for image search is enabled, and the system resultCode returns the default cancel constant.

The solution is to restore the loading mode to the default one.

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.