设为首页 加入收藏

TOP

Android彻底关闭当前应用
2014-11-24 03:27:09 来源: 作者: 【 】 浏览:0
Tags:Android 彻底 关闭 当前 应用

以下方法用于关闭当前应用:


ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
manager.restartPackage(getPackageName());


函数说明:
void android.app.ActivityManager.restartPackage(String packageName)


public void restartPackage (String packageName)
Since: API Level 3


Have the system perform a force stop of everything associated with the given application package. All processes that share its uid will be killed, all services it has running stopped, all activities removed, etc. In addition, a ACTION_PACKAGE_RESTARTED broadcast will be sent, so that any of its registered alarms can be stopped, notifications removed, etc.


You must hold the permission RESTART_PACKAGES to be able to call this method.
Parameters
packageName The name of the package to be stopped.


与当前应用相关的应用、进程、服务等也会被关闭。
会发送 ACTION_PACKAGE_RESTARTED广播。
不要被函数名误导。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android中的handler到事件与消息 下一篇Android将ScrollView移动到最底部

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)
·Linux常用命令60条( (2025-12-25 00:50:40)
·nginx 监听一个端口 (2025-12-25 00:19:30)
·整个互联网就没有一 (2025-12-25 00:19:27)