关闭Android应用程序编程 [英] Close android application programmatically

查看:126
本文介绍了关闭Android应用程序编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何关闭我的应用程序编程?

How can i close my application programmatically?

我用

   finish();

rocess.killProcess(android.os.Process.myPid());

System.exit(0);

moveTaskToBack(true);

但它关闭当前运行的活动,但我需要关闭整个应用程序?

but it closed the current running activity, but i need to close the whole application??

我需要关闭应用程序,以获取一些内存,然后再次重新启动应用程序。

I need to close app to retrieve some memory and then restart application again.

确实有一种方法清除应用程序的所有内存?

does there is a way to clear all memory of the application?

推荐答案

在使用你的活动这些行: -

Using these lines in your activity:-

this.finish();
Process.killProcess( Process.myPid() ); 

会杀了你的整个应用程序(假设其运行在一个单一的过程中),它也将释放所有相关的存储。

will kill your whole application (assuming its running in a single process) it will also free any associated memory.

警告:在某些电话上这样做可能会使蓝牙插座,如果你使用的是他们悬挂

WARNING: On some phones doing this may leave bluetooth sockets dangling if you are using them.

这篇关于关闭Android应用程序编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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