Understanding Command Through Adb Shell and Through Code - Android

Execute adb shell commands inside my android application

Instead of:

Process p = Runtime.getRuntime().exec("settings put global policy_control immersive.navigation=*");

try:

Process p = Runtime.getRuntime().exec(new String[]{"settings", "put", "global", "policy_control", "immersive.navigation=*");

exec expects the command to be an array of strings where the first string is the command and the rest are its arguments

Is there an ADB Shell command that tells me the contents of a TextView?

You can use uiautomator here. There is a Python package uiautomator that can help:

from uiautomator import device as d

d(resourceId="id/mytextfield").text

Or if you want to do it the more manual way, the screen contents can be dumped to an XML file using adb shell uiautomator dump. Then you can adb pull it locally, where your script can then parse the XML for the text.



Related Topics



Leave a reply



Submit