屏幕寄希望于第三方编程应用服务 [英] Screen pinning 3rd party apps programmatically

本文介绍了屏幕寄希望于第三方编程应用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在获得设备所有权,我想实现一个方法来指示设备锁定任何特定的应用程序到信息亭模式(或屏幕钉住模式)。因为我有设备所有权,用户没有要求这样做的权限。

After achieving device ownership, I am trying to implement a method to instruct the device to lock any given app into kiosk mode (or screen pinning mode). Since I have device ownership, the user is not asked for the permission to do so.

从开发人员网站上,简短的描述告诉我,这是可以做到什么,我想:

From the developer website, brief description tells me that it is possible to do what I am trying:

http://developer.android.com/about/versions/ Android的5.0.html#ScreenPinning

编程:要激活屏幕寄托编程,呼叫   startLockTask()从您的应用程序。如果请求的应用程序不是一个设备   老板,提示用户进行确认。 设备所有者的应用程序可以   调用setLockTaskPackages()方法,以使应用程序成为pinnable   未经用户确认步骤。

Programmatically: To activate screen pinning programmatically, call startLockTask() from your app. If the requesting app is not a device owner, the user is prompted for confirmation. A device owner app can call the setLockTaskPackages() method to enable apps to be pinnable without the user confirmation step.

这表明,作为设备所有者的应用程序,我可以固定其他应用程序,而无需用户确认......但我不知道怎么样。

This indicates that as a device owner app, I can pin other apps without user confirmation... but I have no idea how to.

我已经能够把我自己的应用程序成为固定模式。

I have been able to put my own app into pinned mode.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

setLockTaskPackages()用于在指定的应用程序(通过他们的包名)就能够以编程方式寄托的无需用户确认。 该 setLockTaskPackages()从被称为你的设备所有者应用的(最有可能在你的 DeviceAdminReceiver onEnabled()法)。

The setLockTaskPackages() is used the specify which applications (through their package names) will be able to programmatically be pinned without user confirmation. The setLockTaskPackages() is called from your device owner app (most probably in your DeviceAdminReceiver's onEnabled() method).

所以,在你拥有者设备的应用程序,你必须是这样的:

So, in you owner device app, you'll have something like :

mDPM.setLockTaskPackages("com.foo.myapp");

然后,在你的com.foo.myapp应用程序,你会被autorized调用:

and then, in your "com.foo.myapp" application, you will be autorized to call :

startLockTask(); 

您的应用程序将立即进入钢钉模式,无需任何用户确认。

Your application will immediately enter the Pinning mode, without any user confirmation.

如果你不先注册与应用程序 setLockTaskPackages ,应用程序将被固定,但用户将必须先确认。

If you don't first register your application with setLockTaskPackages, the application will be pinned but the user will have to confirm first.

还要注意,当一个应用程序是注册 setLockTaskPackages(),它具有比一些不同的行为手动脚的:

Also notice that when an app is registered with setLockTaskPackages(), it has some different behaviours than the manual pin:

  • 用户不能手动长期pressing取消固定应用程序的返回 + 最近的应用的。你必须以编程方式取消固定与 stopLockTask()你的应用;
  • 在家和最近的应用程序按钮是不可见的(未显示)
  • 在当前的应​​用程序是取消固定(通过stopLockTask()),用户将直接返回到首页:不显示屏幕锁定,即使键盘锁设置(模式,code,或任何键盘锁屏)。
  • the user cannot unpin manually the application by long-pressing Back + Recent Apps. You'll have to programmatically unpin your app with stopLockTask();
  • The "Home" and "Recent Apps" buttons are invisible (not displayed)
  • When the app is unpinned (via stopLockTask()), the user will directly go back to Home : no Screen lock is displayed, even if a Keyguard is set (Pattern, code, or whatever Keyguard screen).

这篇关于屏幕寄希望于第三方编程应用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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