Android: Customizing recent apps thumbnail (screenshot by default)

前端 未结 5 806
暖寄归人
暖寄归人 2020-12-07 23:48

The app I\'m working on shows some sensitive information that must not be shown on the \"Recent Tasks\" screen when stopping the app by pressing the home button.

I\'

5条回答
  •  盖世英雄少女心
    2020-12-08 00:46

    There is a way to customize it. You need your Activities with sensitive data to FLAG_SECURE in onCreate before you setContentView. Then you need an empty Activity, which renders whatever you want to have as the customized thumbnail. This usually is some sort of splash screen. This new Activity needs to be the launcher and is the only Activity not FLAG_SECURE. This Activity is launched and in onResume starts your actual Activity with the sensitive data.

    Android OS will take a screenshot of that new Activity at the beginning of your App. Unfortunately the users will also see this Activity for a short moment. Since every other Activity is FLAG_SECURE, Android OS will use the only available screenshot it made at the beginning.

提交回复
热议问题