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
.
精彩评论