开发者

Does using one attribute of configChanges calls onConfigurationChanged() anyway?

开发者 https://www.devze.com 2023-03-27 21:22 出处:网络
If I use this code in my Manifest file: <activity android:name=\".MyAct\" android:label=\"@string/app_name\"

If I use this code in my Manifest file:

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

As you can see I am declaring that the activity shall not be restarted when the screen rotation and keyboard visibility have been changed.

However, does this mean that the method onConfigurationChanged() will be called ONLY in ca开发者_如何转开发se of these two events (in other cases the activity shall restart)?

Or it means that the activity does not restart even if only one attribute has been used?

I haven't been able to find this answer in the documentation.


Correct. It means that the activity does not restart even if only one attribute has been used. The onConfigurationChanged() method will be envoked if one of the attribute occur, i.e for those which are not specified, the activity will restart when they occur.

0

精彩评论

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

关注公众号