how to stop activity recreation on screen orientat

2020-02-05 10:09发布

how i can stop the restarting or recalling of on create() on screen orientation ,i want to stop the recreation of activity on screen orientation. thanks in advance please tell me any better solution its really creating a problem. like in my program i am selecting some picture but on screen orientation the image goes off so thats why i want to stop the recreation of activity on screen orientation.

enter code here
public void onCreate(Bundle savedInstanceState) 
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainwindow);
    Toast.makeText(getApplicationContext(),"a", 1).show();

    bitmap = (Bitmap)getLastNonConfigurationInstance();
    //Toast.makeText(getApplicationContext(),"a1", 1).show();

    if (savedInstanceState != null) 
    {
        bitmap=BitmapFactory.decodeFile(mImageCaptureUri.getPath());
        Toast.makeText(getApplicationContext(),"preview have value", 1).show();
        preview.setVisibility(View.VISIBLE);
        From_Folder.setVisibility(View.GONE);
        From_Camera.setVisibility(View.GONE);
        preview.setImageBitmap(bitmap);


    }

标签: android
7条回答
Animai°情兽
2楼-- · 2020-02-05 10:37

Up to API 13 there was a new value to the configChanges attribute, screenSize

So if you're using large screens make sure to add screenSize in your configChanges attribute:

    android:configChanges="orientation|keyboardHidden|screenSize"
查看更多
登录 后发表回答