Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Toast Messages generated in Screen Pinning?

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.

like image 546
Sangha_development Avatar asked Sep 25 '15 10:09

Sangha_development


People also ask

How do you stop toast messages?

You can use toast. cancel() befor showing next toast.

How do I turn off screen pinning?

To unpin a screen: Gesture navigation: Swipe up and hold. 2-button navigation: Touch and hold Back and Home . 3-button navigation: Touch and hold Back and Overview .

What is a toast notification android?

A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. Toasts automatically disappear after a timeout.

How does screen pinning work?

Android screen pinning is an app-pinning capability on Android devices that facilitates locking an app to the device's screen and restricting other device features and apps from being accessed by the device user. Unpinning apps on Android devices is possible using a security PIN, pattern or password.


2 Answers

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.

like image 158
Jenever Avatar answered Sep 28 '22 22:09

Jenever


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.

like image 45
scorpiodawg Avatar answered Sep 28 '22 23:09

scorpiodawg