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

后端 未结 3 1995
攒了一身酷
攒了一身酷 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:34

    Locking the screen orientation of the invoking Activity fixed the issue for me. If you don't want to lock yours, you can create an Activity with locked orientation just for calling the camera, then returning the result to your 'real' activity.

    To lock the screen orientation, put this into the activity definition in your manifest (both lines):

    android:screenOrientation="portrait"
    android:configChanges="keyboardHidden|orientation|screenSize"
    

    "portrait" can also be "landscape"

提交回复
热议问题