can anybody tell what is use of start activity for result in android

This question already has an answer here:

  • How to manage `startActivityForResult` on Android? 9 answers

  • By calling startActivityForResult with Activity2 , your current activity will be notified when the Activity2 is finished (back button pressed), and this way you can also get information from it.
    This notification you can catch by overriding your activity's onActivityResult method.

    This article about Android startActivity and startActivityForResult might be worth to look at.


    startActivityForResult() allows you to start activity and get some data back. Imagine that you have some file picker activity. You can start it and when user chooses the file, the result is given back to the original activity.

    Also, it can be used if you simply want to ensure that the second activity has successfully done somethings.

    The result code is obtained in onActivityResult method:

    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            // Result OK.d.
            if (requestCode == resultCode) {
                // do something good
            }
        }
    
    链接地址: http://www.djcxy.com/p/52484.html

    上一篇: BitTorrent群中节点的最佳数量是多少?

    下一篇: 任何人都可以告诉android的结果在开始活动中有什么用处