LoginSignup
8
9

More than 5 years have passed since last update.

Androidで画面を回転させた時にActivityがリセットされてしまうトラブルを回避

Posted at

概要

Androidで画面を回転させた時にActivityがリセットされてしまうトラブルを回避する方法のメモ。

内容

AndroidManifest.xmlのactivityに

android:configChanges="orientation|screenSize"

を加える。

↓変更後↓

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"

    android:configChanges="orientation|screenSize">
    <!----------------↑------変更部分---------------------->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

のようになります。

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9