Android 屏蔽recent task 按钮

神代码...

来自StackOverFlow。。。http://stackoverflow.com/questions/30979005/block-disable-recent-apps-button

Step 1

Add this permission to the manifest.xml file

<uses-permission android:name="android.permission.REORDER_TASKS" />

Step 2

Put this code in any Activity on which you want to block/disable the recent apps button

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

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

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

I have tried in several devices and it is working perfectly. Pressing the recent apps button may turn the screen black for less than a second but will bring your activity back again.

posted @ 2016-04-07 20:37  一梦轻枫  阅读(1637)  评论(0编辑  收藏  举报