haafab.blogg.se

Android studio fragment activity for result
Android studio fragment activity for result





android studio fragment activity for result

Calling super is mandatory! It won’t work otherwise. For example, your app can start a camera app and receive the captured photo as a result.

  • override the onActivityResult() method and call super.onActivityResult. To receive a result, call startActivityForResult () (instead of startActivity () ).
  • In Activity (the one that hosts the fragment): // Start new activity with the LOADIMAGERESULTS to handle back the results when.

    android studio fragment activity for result

    It seems that fragments override somehow the requestCode.

    android studio fragment activity for result

    But then, I noticed that the requestCode (the int value you need to use when calling startActivityForResult()) had a very strange value: requestCode=132897 I spent some time debugging the code thinking that maybe I used a wrong constant.īut that was not the case. So, I ran my app in debug mode and when I saw that the breakpoint stopped in the onActivityResult method from the activity I said, OK, at least it works here. My first impulse was to move the method inside the activity that hosts the fragment, and that’s what I actually did. Create a New Android Studio Project and select the template as Google Maps Activity. Today I had an issue with onActivityResult() method which was not called inside a fragment. Android allows us to integrate google maps in our application. In such case, we need to override the onActivityResult method that is invoked automatically when second activity returns result.







    Android studio fragment activity for result