如何停止对屏幕方向活动的娱乐? [英] how to stop activity recreation on screen orientation?

查看:95
本文介绍了如何停止对屏幕方向活动的娱乐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以停止重启或屏幕方向回顾上创建(),我想停止活动对屏幕方向的娱乐。由于事先请告诉我任何更好的解决方案的真正创造一个问题。就像在我的计划,我选择了一些图片,但对屏幕方向的图像熄灭所以这就是为什么我要停止活动的娱乐屏幕方向。

 在此输入code
公共无效的onCreate(包savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.mainwindow);
    Toast.makeText(getApplicationContext(),一,1).show();

    位图=(位图)getLastNonConfigurationInstance();
    //Toast.makeText(getApplicationContext(),"a1,1).show();

    如果(savedInstanceState!= NULL)
    {
        位= BitmapFactory.de codeFILE(mImageCaptureUri.getPath());
        Toast.makeText(getApplicationContext(),preVIEW具有值,1).show();
        preview.setVisibility(View.VISIBLE);
        From_Folder.setVisibility(View.GONE);
        From_Camera.setVisibility(View.GONE);
        preview.setImageBitmap(位);


    }
 

解决方案

最多 API 13 有一个新值 configChanges 属性, 屏幕尺寸

因此​​,如果您使用的是大屏幕一定要增加屏幕尺寸在configChanges属性:

 安卓configChanges =定位| keyboardHidden |屏幕尺寸
 

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);


    }

解决方案

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"

这篇关于如何停止对屏幕方向活动的娱乐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆