Terminating The Browser Programmatically
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?
Solution 1:
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);
}
}
}
but also have a look at this answer.
A nice answer, this will give you detailed description of why this method of killing processes is discouraged.
Solution 2:
If you are referring to your own use of WebView
, just finish()
your activity.
If you are referring to some other application, you cannot "close/terminate the browser programmatically", particularly if it is in the foreground.
Post a Comment for "Terminating The Browser Programmatically"