Scripting Windows freeware "adb" (Android Debug Bridge)

Skip to first unread message

Scott Lurndal

Sep 25, 2021, 2:27:21 PMSep 25
Does anyone know the command line command that I can put in a batch file to
allow a Windows freeware adb script to open a specific unique settings page
on Android (aka, an "Activity"), and then to press a button on that page?

There are probably hundreds of Android pages inside of Android applications
that we might want to interact with from Windows so let's just try one.

A simple example is the "reset advertising id" Android settings page.

While the ultimate goal is to be able to reset the Android Advertising ID
automatically (e.g., every time the phone is connected to Windows over USB
or Wi-Fi), the baby steps are to manually reset the Advertising ID on
Android but doing that from the Windows command line whenever you want to.

I'm almost there... as I can bring up the "Reset Advertising ID" Activity
from a Windows 10 command line, but I can't yet _press_ the "reset" button!

Does anyone know how to _press_ that reset button from a Windows script?
This is the method I used on Windows to bring up the reset adid Activity.
[Note that I am not rooted and that I'm using Windows 10 & Android 11.]

1. Install & test adb on Windows as per instructions here.

2. Connect your phone & run a quick test that you have a connection.
C:\> adb pull /system/etc/hosts .\hosts.txt
[That should copy the Android hosts file over to your Windows machine.]

Find the number of packages you have which have "google" in the name.
C:\> adb shell pm list packages google | find /c /v ""

3. Now bring up the gms "Reset AD ID" Activity on Android from Windows:
C:\> adb shell am start -n
That should pop up the "Reset AD ID" settings page on your phone.
[GMS is a set of "google mobile services" products native on Android.]

You can close that page on Android from Windows by running this:
C:\> adb shell am force-stop
Which you can put into a "closegms.bat" one-line file for convenience.

The missing next step is how to _press_ that "Reset" button on the Activity
Reply all
Reply to author
0 new messages