如何杀死其他应用程序?

发布于 2024-10-08 20:13:08 字数 575 浏览 0 评论 0原文

如何杀死其他应用程序?我可以使用意图启动其他应用程序,但找不到杀死它们的方法。

这将启动应用程序:

Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setComponent(
        new ComponentName("com.bla.bla...", 
            "com.bla.bla.Main"));
    context.startActivity(i);

我尝试使用活动管理器的终止功能

killBackgroundProcesses(String packageName)

,但这没有任何作用。

我也尝试过

 appContext.stopService(intent)

,但没有任何作用

How can I kill other applications? I can launch other applications using intents but can't find a way to kill them.

This launches the application:

Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setComponent(
        new ComponentName("com.bla.bla...", 
            "com.bla.bla.Main"));
    context.startActivity(i);

I've tried to use the activity manager's kill

killBackgroundProcesses(String packageName)

but that does nothing.

I've also tried

 appContext.stopService(intent)

but that did nothing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文