Question

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

Était-ce utile?

La solution

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");
                  }
                 }
                }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top