How to make sure there is only one app

天大地大妈咪最大 提交于 2019-12-13 11:00:25

问题


I am developing an app with requirement that one app can be there in android system. No other app can be installed or remove google play store application as well. How can i achieve this?


回答1:


As long as your device runs Lollipop or greater, you will want to set your app as a device owner. Note, this is different than device administrator. An app is granted device owner permissions only during device provisioning at the welcome screen of the Google Setup Wizard. The device owner is restricted when it can be set because of the control it has. Only one app can be the device owner.

A kiosk solution will set a device up with an app as the device owner. It will suspend all packages that shouldn't be available using setPackagesSuspended.

Some additional links you may find helpful (all require device owner for a COSU/kiosk-mode solution):

  • setApplicationHidden
  • addUserRestriction
  • DISALLOW_INSTALL_APPS

Look into the TestDPC app. Google provides source code to it and it will have most, if not everything of what you need.

https://developers.google.com/android/work/build-dpc

https://github.com/googlesamples/android-testdpc

Other solutions I've seen (mostly on pre-Lollipop releases) are to use a custom launcher to hide non-approved apps. This custom launcher is sometimes referred to as a secure launcher, but hiding apps instead of suspending them as the device owner is much less effective. Secure launcher, IMO, is a misnomer.



来源:https://stackoverflow.com/questions/46811159/how-to-make-sure-there-is-only-one-app

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