How to disable Toast Messages generated in Screen Pinning? - android

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.

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.

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.

Related

ADB command to show Remove account screen

I want to add and remove google account from device. Programmatically I heard was difficult. I used following command to show screen to add an account, which is working. However, i am not able to find command which removes / manages accounts. Please suggest correct app/intent to launch from adb (or other alternate possibilities to remove account)
I have tried ACCOUNT_TYPES, EXTRA_ACCOUNT_TYPES etc. abd says - Activity not started, unable to resolve Intent
This command launches add account settings screen
adb shell am start -a android.settings.ADD_ACCOUNT_SETTINGS

showInputMethodPicker from notification not working in Android 9

My app sometimes shows a notification to simplify switching to the app's internal input method. Therefore, I am executing
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).showInputMethodPicker();
when the user clicks the notification.
This has worked so far, but does not always work on Android 9: When my app is in foreground, it works. When it is not, nothing happens. On logcat, I see a warning
"Warning 889 InputMethodManagerService Ignoring
showInputMethodPickerFromClient of uid 10210:
com.android.internal.view.IInputMethodClient$Stub$Proxy#edf46f0".
Is there any way to make this work again?
Update: I have tried to create an activity, calling showInputMethodPicker(); in onResume(). This works (if I use postDelayed() with a relatively long delay which is unfortunate), but I cannot get the activity to close itself automatically. So this doesn't seem to be a good way.
The problem can be solved by setting the WRITE_SECURE_SETTINGS permission for your App.
Unfortunately, this requires issuing one adb command:
adb shell pm grant com.name.app android.permission.WRITE_SECURE_SETTINGS
where com.name.app is the package name of your app.

Adb read contents of an Alert Dialog

i have an android phone connected to my pc, using ADB i can run some commands to the device and get output, now am in a situation where i want ADB to read the contents of an Alert dialog. i have been Googling all day but couldn't find anyone on the internet talking about it.
I need an adb command that can read the message content in that dialog for example
UPDATE: I know some people might tell me to add code for logs in my app, however am talking about the system dialogs, not dialogs from my app, of course i can add log tags in my app that way i can get them but what i want here is the dialogs from the android-system.
If you're running your own app or in a position to change the source of the one you're running, you could find where the message gets drawn and log it using Log.i("YourTag", "TheMessage"). The .i stands for info and there's other log classes you can use (d, e, w, v).
You can then read logs with adb logcat, and filter them if you want by running adb logcat YourTag:* *:S. This tells logcat to show all messages tagged YourTag (* instead of, for example, .i to show info messages only), and silence everything else.

How can I dismiss the android keyguard using adb intent

I am looking for a way to use ADB to dismiss the keyguard in order to automate some tasks.
I would like to start an ACTIVITY (perhaps to call the public method disableKeyguard in android.app.KeyguardManager.KeyguardLock), because I assume that it will work on all (or most) Android devices, but I am unsure of the syntax.
I do not wish to use MonkeyRunner, because it is not present (or perhaps, callable) on all devices. I also cannot send a MENU keycode (adb shell input keycode 82), because this does not dismiss the keyguard on all devices.
Currently I am sending events (low-level touch events), but this needs to be customized for each device, so it is a time consuming task.
Does anyone have a suggestion?
The "Activity Testing" article has a section called Unlocking the emulator or device that addresses this situation.
In short, there isn't a way to do it directly with adb but using disableKeyguard() isn't complicated (see the three lines of example code in the article linked to above). You could easily put together a little app that does nothing but disable the keyguard. It would then just be a matter of
adb install <apk>
adb shell am start <package>/.<activity>
# Whatever you need to automate
adb uninstall <package>
(Where <apk>, <package>, and <activity> all refer to the tiny app that just disables the keyguard.)

How to react on a force close?

I'm developing a first app for android, and I sometimes get a message "this application stopped unexpectedly" and a "close" button.
How can I find out what's wrong? When the phone is connected to the computer, it would show in the Logcat of Eclipse, but my phone is not always connected to my computer. How do you handle that? How do you handle the error reporting in your app when it's not in debuggable status?
How can I configure my app to restart in such an occasion? I have an other app (not developped by me) which sometimes shows the message that it restarted after memory low (or something like that). I'd like to restart my app too when, for whatever reason, it crashed.
Anybody?
I am not sure about the second question but for the first part you can run adb logcat in background. for that just go to the folder location where adb.exe esixts, in command prompt and just type
adb logcat > /data/log.txt &
it will run in the background and store the logs in log.txt file. When you are done with your force close. just type following command
adb pull /data/log.txt .
it will extract the logs, and will put in the current directory location, you can open it using any text editor.
If your device is not connected to a computer, you can see the logcat output using the following app: aLogcat
Also, I'm not sure that restarting an app that has just crashed is a good idea. This could lead to an infinite loop of crashing/restarting.

Categories

Resources