Android 中的家长控制

发布于 2024-12-13 21:35:53 字数 57 浏览 5 评论 0原文

如何在我的应用程序中实现家长控制,即当我的应用程序启动时,所有其他应用程序应该停止运行。 请帮助我。

How to implement parental control in my application i.e when my application starts, all the other applications should stop running.
plz help me.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的黑色迷你裙 2024-12-20 21:35:53

是的,这是可能的。检索正在运行的进程的名称及其 UID,然后终止那些您想要停止的进程。例如,如果您想停止浏览器应用程序,您可以通过这种方式执行此操作。

ActivityManager servMng;
servMng = (ActivityManager)getApplicationContext().getSystemService(ACTIVITY_SERVICE);
                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);
                  }else{
                   mTextVIew.append(list.get(i).processName + "\n");
                  }
                 }
                }

Yes it is possible.Retrieve the name of running processes and their UIDs and then kill those processes which you want to stop.e.g If u want to stop browser app you can do this in this way.

ActivityManager servMng;
servMng = (ActivityManager)getApplicationContext().getSystemService(ACTIVITY_SERVICE);
                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);
                  }else{
                   mTextVIew.append(list.get(i).processName + "\n");
                  }
                 }
                }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文