Camera activity causing uri to go to null when screen orientation changes

后端 未结 3 1979
攒了一身酷
攒了一身酷 2020-12-21 05:04

I set a data member, imageUri, and pass that into an intent that launches the camera activity. In the camera activity I take a picture and the rotate the screen before clic

3条回答
  •  醉梦人生
    2020-12-21 05:13

    I believe imageUri is a field in your activity, right? if you rotate the device the activity is destroyed and restarted, and your field is null. You have to save the URI as part of the state of your activity. There are a few possible methods to achieve that, on is to use onSaveInstanceState(), see here for more details: http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29

提交回复
热议问题