我正在使用以下代码关闭 Xamarin Form 项目中的 Android 应用。
var activity = (Activity)Forms.Context;
activity.FinishAndRemoveTask();
它正在关闭应用程序,但如果我再次点击该应用程序,它不会打开应用程序的新实例,因为我可以看到调试器仍处于 Activity 状态。
有人能帮忙吗?
最佳答案
it is not opening the new instance of the app as the I can see debugger is still active
当你使用 activity.FinishAndRemoveTask()
方法时,这个方法不能杀死你的 Android 应用,它只是意味着:
Finishes all activities in this task and removes it from the recent tasks list.
您可以使用以下代码来实现此功能:
FinishAndRemoveTask();
Java.Lang.JavaSystem.Exit(0);// Terminate JVM
关于android - 在 Xamarin Forms 项目中以编程方式关闭 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45999745/