On my Samsung tablet i want to prevent user change keyboard settings, because malicious user from keyboard settings can block my tablet (used as kiosk).
I override dispatchKeyEvent in activity, but it doesn't called when i click settings button.
I also registered a watchdog to be notified on foreground activity, but the device settings doesn't appear in foreground activity.
Ideas?
SOLVED
This is the solution to get the foreground activity and force close
ActivityManager.RunningAppProcessInfo processInfo = mActivityManager.getRunningAppProcesses().get(0);
if (processInfo != null && processInfo.pkgList != null && processInfo.pkgList.length > 0) {
mCurrentApp = processInfo.pkgList[0];
Runtime.getRuntime().exec(new String[]{"su", "-c", "am force-stop " + mCurrentApp}).waitFor();
}