ADB command to show Remove account screen - android

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

Related

Google Assistant App Actions codelab example not working (Fit Actions) on AndroidTV

I'm trying out this example:
https://codelabs.developers.google.com/codelabs/appactions/#0
I've built the app & installed it on my AndroidTV device, and able to launch it via:
am start -a android.intent.action.VIEW -d "https://fit-actions.firebaseapp.com/start"
but, when I try to run the App Actions Test Tool and try out the suggested actions.intent.START_EXERCISE intent (which is supposedly integrated with the Google Assistant), I just see an error that says, "You don't have an app that can do this". The entire command looks like this:
am start -a android.intent.action.VIEW -d "https://assistant.google.com/services/invoke/uid/00001f0ad064c9a0?intent=actions.intent.START_EXERCISE\&param.exercise=%7B%0A++++%22%40type%22%3A+%22Exercise%22%2C%0A++++%22name%22%3A+%22Running%22%2C%0A++++%22%40context%22%3A+%22http%3A%2F%2Fschema.googleapis.com%22%0A%7D"
Also, I tried directly speaking the request, "Hey Google, start running in Fit Actions", but I get the same error. Any ideas what could be missing?
I just realized that AppActions is not supported on AndroidTV, I tried this example on a Samsung tablet and the test tool launches it just fine. That said, it's still not working when tried with a voice command

I can't get the activity name using adb shell

I know that many people already sent questions similar to this. However, this is a little different.
I have to try to get the current activity from an android app, but it is not possible. Normally, I interact with the app and execute this: adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'. However, it always shows MainActivity. I checked the activity list on APK Info and this list is so little
So, there is some way to start a specific screen of apps similar to this?

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.
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.

How to launch an Android SubSettings Fragment?

For example, how do I launch User Settings? It's not implemented as its own Activity, so I'm not sure how to start it.
Below are some other similar questions but these are either more general or more specific. My question is about starting an arbitrary SubSettings fragment.
How do I call a specific PreferenceFragment from a PreferenceActivity?
Show only wireless system settings on Android 3
You can launch most Android Settings sub-screens by starting the SubSettings Activity and including the :android:show_fragment extra with the appropriate fully-qualified class name of an existing Android PreferenceFragment subclass.
For example, to start UserSettings:
adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.users.UserSettings
To start DeviceInfoSettings:
adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.DeviceInfoSettings
These examples use 'adb shell am start', but in principle you could invoke these in Java code (EDIT: Unfortunately you need to be signed with the system key, otherwise you get a SecurityException). Notice that the key for this extra has a colon at the front of it. To find other Settings, checkout the Android source and look for subclasses of PreferenceFragment in the packages/apps/Settings.
The situation was different in Froyo and before. In those days Activities were used to implement Settings sub-screens, so one could launch directly into a sub-screen (for example SoundAndDisplaySettings) by the usual method of calling startActivity() with a ComponentName or action String. This mechanism still works for some Settings sub-screens. For example, to bring up a wifi picker, you can use
adb shell am start -a android.net.wifi.PICK_WIFI_NETWORK
for MM :
am start -n com.android.settings/com.android.settings.SubSettings -e :settings:show_fragment com.android.settings.applications.RunningServices

Change user id of an app on Android

I have root. So how can I change the user id of an android app? The background is, I have to start an activity of an app not owned by me in my app. But this will only work if the apps have the same user id.
Thank you for your help
You can run the activity of the other app as root by starting the other app's Activity, using the am start command, and run the am start command as root.
See the following places:
Launch an app through adb shell
Launch a script as root through adb
So in the end you would be doing something like `Runtime.exec("su -c \'am start....\'")

Categories

Resources