简体   繁体   English

使用自定义错误消息以编程方式关闭应用程序?

[英]Closing an application programmatically with custom error message?

I want to close my Android application with a method, but it should be shown a custom message (which I define for myself). 我想用一种方法关闭我的Android应用程序,但是应该显示一条自定义消息(我为我自己定义)。
everything I found yet was "How to close my application" and I got more than 10 ways to close my application but I haven't found a way to set a custom message. 我发现的所有内容都是“如何关闭我的应用程序”,我有十多种方法来关闭我的应用程序,但我还没有找到设置自定义消息的方法。
At the moment if my app crashes something like this appears: 目前,如果我的应用程序崩溃,将出现如下所示的内容:
[APPNAME] has been stopped
I want something like this 我想要这样的东西
Congratulations! You found a bug, please submit it.
Is there even a way to do that? 有没有办法做到这一点? All methods I found just closed all activities or just forced an unresolveable error. 我发现所有方法都关闭了所有活动或强制执行了无法解决的错误。

I don't think you need some code from me, but if you do, tell me. 我认为您不需要我提供一些code ,但是如果需要,请告诉我。
(Language should be java and javascript/jQuery should be avoided) (语言应为Java,应避免使用javascript / jQuery)

You could try making a static stop method: 您可以尝试制作静态stop方法:

public static void stop(String message) {
    Log.d(message);
    System.exit(0);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM