将 Android API 函数与 ADB 配合使用 [英] Use Android API functions with ADB
问题描述
是否可以使用 adb 中的 android api 函数?如果可能,这样做的语法是什么?例如,我想从 android.telephony 调用DATA_CONNECTED"函数并获取其返回值.链接:http://developer.android.com/reference/android/telephony/TelephonyManager.html#CALL_STATE_OFFHOOK
Is it possible to use the android api functions from the adb? If its possible, what is the syntax to do so? For example I'd like to call the "DATA_CONNECTED" function from android.telephony and get its return value. Link: http://developer.android.com/reference/android/telephony/TelephonyManager.html#CALL_STATE_OFFHOOK
推荐答案
没有DATA_CONNECTED
函数.它是一个 0x00000002
常量 - getDataState()
函数.
There is no DATA_CONNECTED
function in Android TelephonyManager. It is a 0x00000002
constant - one of possible response codes to the getDataState()
function.
你从 adb shell
调用 getDataState()
的方式是:
The way you call getDataState()
from adb shell
is:
service call phone 32
更新:如果您的手机运行比 jb-mr2 旧的任何东西,命令应该是:
Update: if your phone runs anything older than jb-mr2, the command should be:
service call phone 31
附言刚刚完成了关于 调用 Android 服务的文章ADB shell - 它包含一个小的 bash 脚本,用于查找特定设备的任何服务/方法的调用代码.
P.S. just finished my write-up on Calling Android services from ADB shell - it includes a small bash script to look up calling codes for any service/method for a specific device.
这篇关于将 Android API 函数与 ADB 配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!