Disable recent tasks button on Android 5.0

后端 未结 2 1269
广开言路
广开言路 2021-01-23 14:04

I am working on an application that needs to suppress the recent apps button as it is done in the Toddler Lock application. What I want is user should not be able to exit my app

相关标签:
2条回答
  • 2021-01-23 14:30

    Finally I was able to achieve this by following:

    @Override
    protected void onPause() {
    super.onPause();
    
    ActivityManager activityManager = (ActivityManager) getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE);
    
    activityManager.moveTaskToFront(getTaskId(), 0);
    

    }

    will need permission ...

    <uses-permission android:name="android.permission.REORDER_TASKS" />
    
    0 讨论(0)
  • 2021-01-23 14:36

    You have to write a service which will continuously monitor the top activity. If the top activity is from the package com.android.systemui means the user pressed the recent apps button. So at this time you have maintain the top activity from your application and start the same activity again.

    0 讨论(0)
提交回复
热议问题