编程终止浏览器 [英] Terminating the browser programmatically

查看:89
本文介绍了编程终止浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图关闭/编程终止该浏览器。但我没有发现在默认浏览器类的任何方法。有谁知道怎么样?

I'm trying to close/terminate the browser programmatically. But I did not find any method in the default browser Class. Does anyone know how to?

推荐答案

在Android的杀prcesses是坏主意,这是从来没有鼓励。但如果你仍然想继续这个你可以做这样的事情。

Killing prcesses in android is bad idea and it is never encouraged. but if still you want to continue with this you could do something like this.

List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
    if(list != null){
     for(int i=0;i<list.size();++i){
      if("com.android.browser".matches(list.get(i).processName)){
       int pid = android.os.Process.getUidForName("com.android.browser");
             android.os.Process.killProcess(pid);
      }
     }
    }

也看看这个回答

有一个很好的答案,这会给你为什么杀死进程不要使用这种方法的详细说明。

A nice answer, this will give you detailed description of why this method of killing processes is discouraged.

这篇关于编程终止浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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