使用MonoGame 3.7.1,我在Android上有一个非常基本的游戏设置。关闭/重新打开应用程序时出现一些奇怪的行为。
要退出游戏,我使用此逻辑:
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
{
Activity.MoveTaskToBack(true);
//Exit(); //Originally was using this, neither seems to have changed much
}
但是,恢复应用程序时,它偶尔会(似乎是随机的)打开,然后立即关闭(不会崩溃)。它并不总是这样做,有时它会返回到先前的状态而没有任何问题。如果我再次尝试恢复它,它将正常打开。
我已经捕获了显示此行为here的视频。值得注意的是,没有崩溃发生。这是通过Visual Studio在Debug中运行的,并且通过USB连接了电话,因此如果发生崩溃我就知道了。即使不在调试模式下,也会发生此行为。
意外关闭发生时的调试输出是这样:
05-22 23:27:05.228 E/SensorManager(26381): registerListenerImpl sensorName:BMI160_ACCELEROMETER Accelerometer Non-wakeup,isWakeUpSensor:false,callingApp: TestGame.TestGame,callingPid:26381,callingUid:10569
05-22 23:27:05.245 D/DecorView(26381): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@8012b96[MainActivity]
05-22 23:27:05.265 W/monodroid-assembly(26381): typemap: unable to find mapping to a managed type from Java type 'com/google/android/gles_jni/EGLSurfaceImpl'
05-22 23:27:05.265 D/MonoGame(26381): GraphicsDeviceManager.ResetClientBounds: newClientBounds={X:0 Y:137 Width:1080 Height:1799}
05-22 23:27:05.265 D/AudioTrack(26381): ClientUid 10569 AudioTrack::start
05-22 23:27:05.317 E/SensorManager(26381): unregisterListenerImpl callingApp: TestGame.TestGame,callingPid:26381,callingUid:10569
05-22 23:27:05.325 D/ (26381): PlayerBase::stop() from IPlayer
05-22 23:27:05.325 D/AudioTrack(26381): ClientUid 10569 AudioTrack::stop
05-22 23:27:05.325 D/AudioTrack(26381): stop(1656): called with 1772 frames delivered
Thread finished: <Thread Pool> #17
Thread started: <Thread Pool> #28
对我来说唯一突出的是typemap: unable to find mapping...
,GraphicsDeviceManager.ResetClientBounds
和Thread finished: <Thread Pool> #17
行。
也就是说,当正确加载时出现类似消息时,这些可能完全不相关。
有什么想法吗?