Android Disable the last task button, as in SureLock

Anyone who knows how to disable the "Recent Application Application" button when launching an authorized application in the application, as in SureLock Kiosk Lockdown Lock ? If so, can you provide codes for this?

+5
android kiosk kiosk-mode
Jan 28 '14 at 9:36 on
source share
4 answers

To disable the last button, add this code to your main activity:

@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (!hasFocus) { windowCloseHandler.post(windowCloserRunnable); } } private void toggleRecents() { Intent closeRecents = new Intent("com.android.systemui.recent.action.TOGGLE_RECENTS"); closeRecents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); ComponentName recents = new ComponentName("com.android.systemui", "com.android.systemui.recent.RecentsActivity"); closeRecents.setComponent(recents); this.startActivity(closeRecents); } private Handler windowCloseHandler = new Handler(); private Runnable windowCloserRunnable = new Runnable() {@Override public void run() { ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; if (cn != null && cn.getClassName().equals("com.android.systemui.recent.RecentsActivity")) { toggleRecents(); } } }; 
+2
Jul 01 '15 at 17:35
source share

From source

 public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); Log.d("Focus debug", "Focus changed !"); if(!hasFocus) { Log.d("Focus debug", "Lost focus !"); Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); sendBroadcast(closeDialog); } } 
+1
Jan 28 '14 at 9:38
source share
  @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); Log.d("Focus debug", "Focus changed !"); if(!hasFocus) { Log.d("Focus debug", "Lost focus !"); Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); sendBroadcast(closeDialog); } } 
0
Jun 21 '17 at 12:44 on
source share

To disable the last application button when starting other applications, you can create a service.

public class StatusBarService extends Service {

 private static final String TAG = StatusBarService.class.getSimpleName(); private volatile boolean isRunning; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); isRunning = true; // Lock a recentApps button RecentAppLockerThread thread = new RecentAppLockerThread(); new Thread(thread).start(); } /** * Lock a recent apps button * * */ private class RecentAppLockerThread implements Runnable { @Override public void run() { while (isRunning) { Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); sendBroadcast(closeDialog); } } } @Override public boolean stopService(Intent name) { isRunning = false; return super.stopService(name); } @Override public void onDestroy() { super.onDestroy(); isRunning = false; } 

}

-one
Jan 10 '15 at 18:48
source share



All Articles