2

I want to close my Android application with a method, but it should be shown a custom message (which I define for myself).
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.
(Language should be java and javascript/jQuery should be avoided)

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • This might help? https://stackoverflow.com/questions/3463328/how-to-display-custom-message-before-force-close-or-anr-message-will-occur – Dr Ken Reid Aug 14 '17 at 14:47
  • Are you looking for a toast message? – Michael Aug 14 '17 at 14:50
  • I want to close the application and then want to display a costum message, but as I overread this question I think he wants a costum "not responding" message – user8442416 Aug 14 '17 at 14:51
  • @Michael I dont know what you mean. I have if (and else if) statements and if every statement isnt true it should `return null;` (this is impossible) but I still want to have this "feature" because I know how to force this "impossible" error. I know this is a but confusing, I'm sorry for that, I hope you can understand this ^^" – user8442416 Aug 14 '17 at 14:54
  • when you say "Closing an application programmatically", Do you mean when your app crash ? so you want to show a custom "crash dialog" when your app is forced closed? – Angel Koh Aug 14 '17 at 14:58
  • you can try the links below to "Auto-restart" your app when it crash (but instead of starting the "MainActivity", you can start a "SubmitBugActivity") . hope it make sense. https://stackoverflow.com/a/2903866/908821 and https://medium.com/@ssaurel/how-to-auto-restart-an-android-application-after-a-crash-or-a-force-close-error-1a361677c0ce – Angel Koh Aug 14 '17 at 15:01

1 Answers1

0

You could try making a static stop method:

public static void stop(String message) {
    Log.d(message);
    System.exit(0);
}
camo5hark
  • 214
  • 1
  • 5