how can I save a bitmap with onRetainNonConfigurationInstance() for screen orientation?

后端 未结 1 2002
暖寄归人
暖寄归人 2021-01-05 10:48

In my class view phone cam will be opened and programme shows the bitmap after user take photo from phone cam but at the same time the user rotates the screen to \"landscape

相关标签:
1条回答
  • 2021-01-05 11:37

    Save it onSaveInstanceState:

      @Override
      public void onSaveInstanceState(Bundle toSave) {
        super.onSaveInstanceState(toSave);
        toSave.putParcelable("bitmap", bitmap);
      }
    

    And get it back onCreate:

     @Override
      public void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        if (savedState != null) bitmap = savedState.getParcelable("bitmap");
      }
    
    0 讨论(0)
提交回复
热议问题