如何在Android(SDL2)上干净地退出jni应用程序

时间:2016-12-19 15:24:47

标签: android c++ android-ndk sdl

我使用SDL2编写了一个C ++应用程序,我正在使用SDL提供的JNI处理程序:

https://www.libsdl.org/tmp/SDL/android-project/src/org/libsdl/app/SDLActivity.java

我只是将其扩展为在我的本机代码上调用main:

package com.test.testapp;

import org.libsdl.app.SDLActivity;

public class Testapp extends SDLActivity
{

}

我尝试过的一些事情:

  • 如果我让main返回正常,我会注意到Android抛出了一个UI错误而我的应用程序仍在运行
  • 在我的原生应用程序中添加一些关机处理后:

-

 SQL_Quit();
   std::exit(0);

-

这似乎根据logcat杀死了进程:

-

2-19 10:03:27.344  2125  2142 I SDL/APP : ==================================================== 
12-19 10:03:27.344  2125  2142 I SDL/APP : GameInstance::shutdown -- shutting down... 
12-19 10:03:27.360  2125  2142 I SDL/APP : GameInstance::shutdown -- shutdown complete, exiting... 
12-19 10:03:27.360  2125  2142 I SDL/APP : ==================================================== 
12-19 10:03:27.465   911  4440 D GraphicsStats: Buffer count: 6
12-19 10:03:27.465   911  4439 I WindowManager: WIN DEATH: Window{e8e4c8d u0 com.test.testapp/com.test.testapp.Testapp}
12-19 10:03:27.465   911  4439 W WindowManager: Force-removing child win Window{27798bc u0 SurfaceView - com.test.testapp/com.test.testapp.Testapp} from container Window{e8e4c8d u0 com.test.testapp/com.test.testapp.Testapp}
12-19 10:03:27.465   911 19431 I sensors : activate
12-19 10:03:27.466   911 26120 I ActivityManager: Process com.test.testapp (pid 2125) has died
12-19 10:03:27.466   911  4439 I WindowManager: Destroying surface Surface(name=SurfaceView - com.test.testapp/com.test.testapp.Testapp) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2457 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowState$DeathRecipient.binderDied:1780 android.os.BinderProxy.sendDeathNotice:688 
12-19 10:03:27.466   911 26120 D ActivityManager: cleanUpApplicationRecord -- 2125
12-19 10:03:27.466   911 26120 W ActivityManager: Force removing ActivityRecord{c279606 u0 com.test.testapp/.Testapp t766}: app died, no saved state
12-19 10:03:27.467   911 19431 I nanohub : queueActivate: sensor=1, handle=1, enable=0
12-19 10:03:27.469   911  4439 I WindowManager: Destroying surface Surface(name=com.test.testapp/com.test.testapp.Testapp) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowState$DeathRecipient.binderDied:1780 android.os.BinderProxy.sendDeathNotice:688 <bottom of call stack> 
12-19 10:03:27.472   911  6772 W WindowManager: Failed looking up window
12-19 10:03:27.472   911  6772 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@ff7be42 does not exist
12-19 10:03:27.472   911  6772 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9100)
12-19 10:03:27.472   911  6772 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9091)
12-19 10:03:27.472   911  6772 W WindowManager:     at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1777)
12-19 10:03:27.472   911  6772 W WindowManager:     at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
12-19 10:03:27.472   911  6772 I WindowManager: WIN DEATH: null

但是,在执行此操作后,我注意到我的应用程序窗口仍然存在于Android窗口历史记录中。我不确定这个的正确用语是什么,但我设备上的方形按钮给了我所有打开窗口的列表。当我从这个列表中选择我的应用程序时,它实际上会重新启动它(因为它被杀死了)但是我想从这里删除窗口,因为它给出了它仍在运行的外观。

0 个答案:

没有答案
相关问题