3

I know that this question was asked before here Block/disable recent apps button, but the answer is not working.

@Override
protected void onPause() {
    super.onPause();

    ActivityManager activityManager = (ActivityManager) getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE);

    activityManager.moveTaskToFront(getTaskId(), 0);
}

I used this code on 5.1 SDK. It's working, but the same program on 6.0 device is not working.

I want to make screen lock but have not found any solution on block recent app button

Community
  • 1
  • 1
user3106818
  • 198
  • 1
  • 2
  • 17

2 Answers2

0

the best solution to this will be that you can reduce the time to show recent apps to almost zero many apps do so....instead of trying to block the recent apps button try showing recent apps to minimal time...its a work around and it should suit your need

tanmeet
  • 220
  • 2
  • 11
  • how can i reduce the time to show recent apps to almost zero – user3106818 May 04 '16 at 06:22
  • Well that is easy u can use thread and set timer there when u want to show your recent apps – tanmeet May 04 '16 at 06:34
  • also you can use these flags to clear recent apps or just bring your app to the front....FLAG_ACTIVITY_NEW_TASK,FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,FLAG_ACTIVITY_SINGLE_TOP,FLAG_ACTIVITY_REORDER_TO_FRONT,FLAG_ACTIVITY_CLEAR_TOP. you must ensure you use proper combination of these flags – tanmeet May 04 '16 at 06:53
0

i found another way to wipe recent apps.Yes you can disable all hardware keys you should google how to disable hardware keys it can be done on rooted devices and through it you can.The key to disable recent app will be (KeyEvent.KEYCODE_APP_SWITCH); KEYCODE_APP_SWITCH= Key code constant: App switch key. Should bring up the application switcher dialog.

ill share a small sample code to help you.

List<Integer> currentHdKeys = new ArrayList<Integer>();
if (SharedPref.recentApps())
        {
            currentHdKeys.add(KeyEvent.KEYCODE_APP_SWITCH);
        }

now just use recentapps method to set wiping of recent apps to true or false. please give me an up vote if you like it

tanmeet
  • 220
  • 2
  • 11