1

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();
}
Premier
  • 3,952
  • 6
  • 39
  • 56

1 Answers1

0

I hope this will solve your problem. Also check this library, and code from this article.

Community
  • 1
  • 1
Paritosh
  • 2,029
  • 3
  • 23
  • 37
  • Thanks. It is different. I need only block the settings screen for keyboard. Let me check with onWindowFocusChange works. I hope :) – Premier Apr 24 '15 at 10:21