整理应用程序/活动后显示敬酒:机器人 [英] Android: Show toast after finishing application / activity

查看:297
本文介绍了整理应用程序/活动后显示敬酒:机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想说明一个简单的烤面包,退出应用程序时。问题是,该敬酒不显示。我想这是因为活性的研究完成后,或因为System.exit的(0),但我不知道如何解决它。有没有人有一个提示?谢谢!

在我的活动,我有以下code:

  Toast.makeText(这一点,退出应用程序,Toast.LENGTH_SHORT).show();
ExitApp命令();公共无效ExitApp命令(){
  App.getInstance()退出()。
  完();
}

和在应用程序的mehod退出:

 公共无效的exit(){
   System.exit(0);
}


解决方案

这是可取的,你打电话完成关闭您的应用程序,而不是调用 System.exit(0); 因为这种做法将彻底杀死你的申请。 System.exit()杀死你的整个过程。
完成()只是隐藏,停止,并破坏你的活动。你的进程仍在运行。

您可以只用完成(); 关闭您的活动,这应该解决您的问题。

http://groups.google.com/group/android-developers/browse_thread/thread/63de8a9cdffa46a3?pli=1

I want to show a simple toast, when exiting an application. The problem is, that the toast is not shown. I assume it is because the acitivity is finished or because of System.exit(0), but I don't know how to solve it. Does anyone have a tip? Thanks!!

In my activity I have the following code:

Toast.makeText(this,"Exit application.",Toast.LENGTH_SHORT).show();
exitApp();

public void exitApp (){
  App.getInstance().exit();
  finish();
}

And the mehod exit in App:

public void exit() {
   System.exit(0);
}

解决方案

It is advisable that you call finish to close your application rather than calling System.exit(0); since this approach will kill your application completely.System.exit() kills your entire process. finish() just hides, stops and destroys your activity. Your process is still running.

You can just use finish(); to close your activity and this should solve your problem.

http://groups.google.com/group/android-developers/browse_thread/thread/63de8a9cdffa46a3?pli=1

这篇关于整理应用程序/活动后显示敬酒:机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆