开发者

How to Show Activity at the time of orientation change in Android?

开发者 https://www.devze.com 2023-02-16 23:50 出处:网络
When I turn th开发者_Go百科e device fromportrait to landscape at that time my activity is restarted. For that Activity I need to use both portrait and landscape mode.

When I turn th开发者_Go百科e device from portrait to landscape at that time my activity is restarted. For that Activity I need to use both portrait and landscape mode.

How to Show my Activity?


add this line in manifest file android:configChanges="orientation|keyboardHidden" here

<activity android:name=".imgview"
                  android:configChanges="orientation|keyboardHidden"   
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

and where u can override for restart . in my functions it's update listitems and some other function : example

  public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.e("ScreenMode",""+screenMode); 
        if(screenMode==1)
        {Log.e("ScreenMode",""+screenMode);
            buildUrl(result,startPage);
            showImageList();
        }

        if(screenMode==2)
        {
            showOneImage(forFunc);
        }
        if(screenMode==0)
        {
            startOMG();
        }
    }


To avoid getting restarted use android:configChanges="keyboardHidden|orientation" in your AndroidManifest for your Activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消