onActivityResult never called

后端 未结 9 822
梦谈多话
梦谈多话 2020-12-17 10:04

So far, I used the startActivity function with success and now that I need to use the startActivityResult, I have a problem.

When using this function, the activity

相关标签:
9条回答
  • 2020-12-17 10:30
    android:noHistory="true" 
    

    like

    android:launchMode="singleInstance"
    

    will stop onActivityResult from receive result.

    0 讨论(0)
  • 2020-12-17 10:31

    There is bug in android API. In startActivityForResult(intent, requestCode); This funktion does work as long as requestCode = 0. However, if you change the request code to anything other than zero, the ApiDemos will fail (and OnActivityResult won't be called). Found here:

    [EDIT: Link removed as google group overrun with spam]

    0 讨论(0)
  • 2020-12-17 10:32

    In my case, I didn't realize I was calling startActivityForResult from an activity that had the android:noHistory attribute set to true in the manifest. Therefore, the onActivityResult was never called as there was no activity instance anymore.

    0 讨论(0)
  • 2020-12-17 10:34

    Did you add the setResult() call in your MoodPicker class ?

    0 讨论(0)
  • 2020-12-17 10:38

    My silly mistake. Might help someone.

    I kept onActivityResult(...) in another class. It has to be as a method in the class where the startActivityForResult() is called.

    0 讨论(0)
  • 2020-12-17 10:42

    I had same problem and solved it: Just remove

    android:launchMode="singleInstance"
    
    0 讨论(0)
提交回复
热议问题