android - 在 Xamarin Forms 项目中以编程方式关闭 Android 应用程序

标签 android xamarin.forms

我正在使用以下代码关闭 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/

相关文章:

java - 使用Recyclerview解析Json

android - Xamarin.Forms 中心标题和透明导航栏 - Android

c# - 将图像发送到休息服务 xamarin 表单

android - PubNub 订阅回调错误

c# - Android 不支持全局 PushAsync,请使用 NavigationPage

页面返回时 Xamarin 标签丢失文本对齐

c# - INotifyPropertyChanged 未触发 PropertyChanged

java - 对话框中的联系人选择器

java - 将 BigDecimal 值添加到 editText - Android、Java

android - 如何自动启用网络位置提供程序