onCreate called before and after onActivityResult

后端 未结 3 1600
北荒
北荒 2020-12-19 17:30

I try open camera following way:

...
    private void runCamera() {
        String storageState = Environment.getExternalStorageState();
        if (storageS         


        
相关标签:
3条回答
  • 2020-12-19 18:08

    onDestroy is not guaranteed to be executed on any android version, if it does you should do something quick and return

    also see this Activity OnDestroy never called?

    0 讨论(0)
  • 2020-12-19 18:10

    Actually the camera causes the orientation change in your activity that is why your activity is being destroyed and recreated.

    Add this in your manifest file it will prevent the orientation change and your activity will not get destroyed and recreated.

    <activity
        android:name=".YourActivity"
        android:configChanges="orientation|keyboardHidden"
        android:screenOrientation="portrait" >
    </activity>
    

    Activity killed / onCreate called after taking picture via intent

    0 讨论(0)
  • 2020-12-19 18:18

    onDestroy is not guaranteed to be called. Make sure you save persistent state in onPause rather than onStop and onDestroy. You should never rely on either onStop or onDestroy to be called.

    0 讨论(0)
提交回复
热议问题