在Android 5.0上禁用“近期任务"按钮 [英] Disable recent tasks button on Android 5.0

查看:114
本文介绍了在Android 5.0上禁用“近期任务"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个需要抑制最近使用的应用程序"按钮的应用程序,就像在幼儿锁"应用程序中所做的那样.我想要的是用户应该不能通过按最近使用的应用程序"按钮退出我的应用程序.

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 application by pressing the recent apps button.

幼儿锁( https://play.google.com/store/apps/details?id = marcone.toddlerlock& hl = zh_CN ),只要您按最近使用的应用程序"按钮,屏幕就会闪烁一点,但该应用程序会返回到自己的活动状态.即使我们连续多次按最近使用的应用程序"按钮并设法在几毫秒后显示最近使用的应用程序"屏幕,应用程序仍会返回其自己的活动.

In toddler lock (https://play.google.com/store/apps/details?id=marcone.toddlerlock&hl=en) whenever you press the recent apps button the screen flashes a bit but the app return to its own activity. Even if we press the recent apps button multiple times in quick succession and manage to display the recent apps screen after a few milliseconds the app return to its own activity.

我知道幕后一定有一些服务,但我无法确切地弄清楚.

I know there must be some service that which is behind the scenes but i cannot exactly figure out.

任何人都可以告诉我,幼儿锁"应用程序如何设法抑制最近使用的应用程序"按钮.我需要在应用程序中实现完全相同的行为.

Can anyone tell me how does the Toddler Lock application manages to suppress the recent apps button. I need to implement exactly same behavior in my application.

我尝试了以下链接中给出的答案:更改getRecentTasks的结果

I tried the answer that is given on the link below: Altering the result of getRecentTasks

android拦截最近的应用程序按钮但这些功能不适用于Android Lollipop.

and android intercept recent apps button but these does not work on Android Lollipop.

如果可以在我的应用程序中使用主屏幕来执行此操作,请也考虑一下.

If there is a way to do this using a home screen in my application please consider that as well.

推荐答案

最后,我可以通过以下方式实现此目标:

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);

}

将需要许可...

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

这篇关于在Android 5.0上禁用“近期任务"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆