尚无官方支持-通过Task Locking API支持android L
The L Developer Preview introduces a new task locking API that lets
you temporarily restrict users from leaving your app or being
interrupted by notifications. This could be used, for example, if you
are developing an education app to support high stakes assessment
requirements on Android. Once your app activates this mode, users will
not be able to see notifications, access other apps, or return to the
Home screen, until your app exits the mode.
编辑:正如您所说,您使用L时这已经过时了-但我在这里留给其他人以提示
说-您今天也可以在没有root的情况下进行此类工作(例如,某些硬件上的信息亭模式的应用).这并不简单-并且没有适用于所有设备的解决方案-但是如果您需要它,可以使用以下技巧来使其工作:
?-对主屏幕意图做出反应(并将其设置为默认)
?-当您进入背景时-再次展现自己的前景
?-..