Android的关闭其他应用程序 [英] Android-Close Other Apps

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

问题描述

我有一些code将使用意图,但我能做些什么来关闭或杀死其他的应用程序?启动不同的应用程序

下面是启动code(伟大工程):

 意向书我=新意图();
  i.setAction(Intent.ACTION_MAIN);
  i.addCategory(Intent.CATEGORY_LAUNCHER);
  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  i.setComponent(
     新的组件名(resolveInfo.activityInfo.applicationInfo.packageName,
       resolveInfo.activityInfo.name));
 

我想杀了后台进程,但没有运气:

  ActivityManager activityManager =(ActivityManager)context.getSystemService(context.ACTIVITY_SERVICE);
  activityManager.kil​​lBackgroundProcesses(com.pandora.android);
 

我也试过这个杀死它:

  context.stopService(新意图(上下文的Class.forName(com.bla.bla)));
 

更新:

我要杀死其他的应用程序,因为我启动其他应用程序和用户都要求这个附加功能(自动杀是自动启动的自然延伸)。请回答如何做到这一点的code中的问题。我所了解的高级任务经理因此它是可能的,但怎么样?

解决方案
  

但我能做些什么来关闭或杀死其他的应用程序?

您不知道。您的用户可以退出,其他应用程序,当他们想。

I have some code that will launch a different application using intents but what can I do to close or kill the other app?

Here is the launch code (works great):

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(resolveInfo.activityInfo.applicationInfo.packageName, 
       resolveInfo.activityInfo.name));

I tried to kill the background processes but no luck:

ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
  activityManager.killBackgroundProcesses("com.pandora.android");

I also tried this to kill it:

context.stopService(new Intent(context, Class.forName("com.bla.bla")));

Update:

I want to kill other applications because I launch other applications and users have requested this additional feature (auto kill is a natural extension of auto launch). Please answer the question of how to accomplish this in code. I know about Advanced Task Mgr so it is possible but how?

解决方案

but what can I do to close or kill the other app?

You don't. Your user can exit that "other app" when they wish to.

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

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