Situation: We are serving up a webpage on a local server using Firefox browser. If the user is in the middle of a process and hits the back button on the Android device, it gets caught up in a loop that has to be resolved by logging out or terminating the firefox browser by removing it recent app list. I am trying to do this through an app made on my end, as it is not feasible to trust the end users to know to do this every time it happens. My app currently serves up the webpage in private mode as to not maintain the credentials from instance to instance, but I need the program to terminate firefox or at least remove it from the recents list, or even disabling the back button all together would be fine. Any ideas or other ways of going about this? This is all this device is meant to do. It does not need any other functionality. It is running Marshmallow on a Zebra Tech device.
I've tried this, and can't get it to work.
private void terminateBrowserProcesses() {
Log.d("MyApp", "terminateBrowserProcesses() called");
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.AppTask> appTasks = activityManager.getAppTasks();
for (ActivityManager.AppTask appTask : appTasks) {
if (appTask.getTaskInfo().baseActivity.getPackageName().equals("org.mozilla.firefox")) {
appTask.finishAndRemoveTask();
Log.d("MyApp", "removed from list");
}
}
}