Coming back from Camera Intent crashes Activity

后端 未结 3 1104
广开言路
广开言路 2021-01-25 06:54

I have an Activity that launches a Camera Intent like this (nothing special):

    Intent intent = new Intent(\"android.media.action.IMAGE_CAPTURE\");
    File ph         


        
3条回答
  •  星月不相逢
    2021-01-25 07:33

    The quick and dirty route would be to handle the orientation change yourself. If your application doesn't have a different layout for landscape and portrait, then this is a good route to take. Here's how.

    Add android:configChanges="orientation" to your Activity in the AndroidManifest.

    The other thing you can do is make sure your onSaveInstanceState is persisting the camera data and any other data you may be using so that when the application reloads itself, you can reload that data in onRestoreInstanceState. If you share your LogCat errors, you'd probably see a NullPointerException which is because the data is being lost on the rotate. I'd put my money its the camera data.

提交回复
热议问题