Android handles runtime changes to the language, location, and hardware by terminating and restarting
each application and reloading the resource values.
This default behavior isn’t always convenient or desirable.
To have an Activity listen for runtime configuration changes
- add an android:configChanges attribute to its manifest node
- specifying the configuration changes you want to handle
Configuration changes you can specify
orientation
keyboardHidden
fontScale
locale
keyboard
touchscreen or navigation
<activity
android:name=".TodoList"
android:label="@string/app_name"
android:theme="@style/TodoTheme"
android:configChanges="orientation | keyboardHidden"/>
@Override
public void onConfigurationChanged(Configuration _newConfig)
{
super.onConfigurationChanged(_newConfig);
if (_newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{}
if (_newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO)
{}
}
No comments:
Post a Comment