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
Timepicker in Preferencescreen
Usb Device Access Pop-Up Suppression
"Unable to Locate Adb" Using Android Studio
How to Programmatically Add Buttons into Layout One by One in Several Lines
Use Tab with New Toolbar (Appcompat V7-21)
Emulator Error: This Avd's Configuration Is Missing a Kernel File
Is There a Better Way to Refresh Webview
How to Implement Filterable in Realmrecyclerviewadapter
Email Address Validation in Android on Edittext
Get the Current Fragment Object
How to Set Relativelayout Layout Params in Code Not in Xml
How to Globally Force Screen Orientation in Android
Understanding Command Through Adb Shell and Through Code - Android
Android: How to Overlay a Bitmap and Draw Over a Bitmap
Android Activity Ondestroy() Is Not Always Called and If Called Only Part of the Code Is Executed