Altering the result of getRecentTasks

ぃ、小莉子 提交于 2019-11-27 14:14:46

Credit goes to the author of Toddler Lock, with whom I spoke about the issue. Errors introduced are entirely mine.

Create within your manifest a disabled activity with affinity equal to the empty string. In your program, enable it and then start it up using an intent flagged FLAG_ACTIVITY_NEW_TASK. It will show up in the recent activities. Disable the task and it disappears from the display.

Make enough of these and you flood the recent activities display. If it has a way to go back more activities than you have dummy activities the user will be able to get out of your program.

Make sure you disable the tasks when you exit, and make sure that if you select one of those tasks from recent activities your program does something reasonable.

Here's an example of two of the tasks in my manifest:

    <activity android:name="com.foo.android.recentactivity.Clear1"
              android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
              android:label="."
              android:enabled="false"
              android:icon="@drawable/clearicon"
              android:taskAffinity="" />
    <activity android:name="com.foo.android.recentactivity.Clear2"
              android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
              android:label="."
              android:enabled="false"
              android:icon="@drawable/clearicon"
              android:taskAffinity="" />

You can't do this from an application. You would need to build a custom system image with the behavior you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!