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="" />
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…