In my Activity onCreate method I create and Intent (say to launch the camera) and call startActivityForResult. The problem is that onCreate is called twice and the Intent is launched twice. Both are received in onActivityResult.
What is going on here? How should I automatically launch an Intent when my Activity loads? I tried calling startActivityForResult in onStart, but it is still called twice.
Thanks.
onCreateis normally called when you return from another activity, like in your example. The activity lifecycle docs by Google are a bit misleading in this respect (they make you thinkonCreateonly called once during the app lifecycle).Your best bet is to save your state in
onSaveInstanceState, e.g. add acameraCalledflag, and then check that flag inonCreateto prevent a loop.