ImageView becomes blank on Screen orientation change

后端 未结 3 491
野趣味
野趣味 2021-01-21 16:58

I am using the below line to set my ImageView.

    Bitmap bm = Media.getBitmap(getContentResolver(), capturedImage);
                    Bitmap bm1=Bitmap.creat         


        
相关标签:
3条回答
  • 2021-01-21 17:46

    Proper way to it is to save the bitmap in onRetainNonConfigurationInstance()

    Here is an example: http://developer.android.com/guide/topics/resources/runtime-changes.html

    0 讨论(0)
  • 2021-01-21 17:46

    You should save capturedImage in your onSaveInstanceState method, and then check in your onRestoreInstanceState method to see if you saved it and then re-execute the code you have above. See the answer of Saving Android Activity state using Save Instance State for an excellent example of how this would work.

    0 讨论(0)
  • 2021-01-21 18:03

    Try adding android:configChanges="orientation|keyboardHidden" to your Activity tag in your AndroidManifest. Take a look here for more details.

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