How to disable Toast Messages generated in Screen Pinning?

社会主义新天地 提交于 2019-12-04 16:27:57

问题


i'm developing lockscreen application, and i want to disable home button,

my app is - Device Owner and Device Administrator

now i'm usnig screen pinning for disable home button.

but if i started activity each time i get msg "Screen pinned" and on close "Screen Unpinned" and if click on home then, "Unpinning isn't allowed by your organisation"

I want to remove all those toast messages.


回答1:


Assuming you used the ADB to list your app as a Device Owner, you can use a similar command prompt to disable all toast messages:

adb shell appops set android TOAST_WINDOW deny

For this command to work, cd to the directory where your adb.exe resides (except if you added it to the PATH). This will disable all toast messages to the android device that is connected (virtual or not). If there are multiple devices, the first one found will be selected.




回答2:


There seems to be no override or "whitelist" or policy that allows even a device owner to override this message.

Here's the code that shows the toast: http://androidxref.com/6.0.1_r10/xref/frameworks/base/services/core/java/com/android/server/am/LockTaskNotify.java#74.

Here's the code that calls this show method when a locked task is shown: http://androidxref.com/6.0.1_r10/xref/frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java#3919.

There are no flags or resources that can be overridden here as far as I have found. If you have access to source, you will need to comment out the line that invokes show.



来源:https://stackoverflow.com/questions/32780113/how-to-disable-toast-messages-generated-in-screen-pinning

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