解决方法很简单,在android项目AndroidManifest.xml文件中的activity中添加如下内容:
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
这个设置是很全的一个,基本上保证了你随便折腾,都不会重新运行游戏。
游戏重新启动,是因为上述原因发生变化后,导致activity的生命周期重新运行,执行了onCreat()方法。游戏中用不到这么多设置,需要哪个设置哪个就好了。