admin管理员组

文章数量:1559729

文章目录

  • 1. 通过 telnet 与模拟器通信
    • 1.1 无法使用telnet
  • 2.发送短信
    • 2.1 提示:KO: unknown command, try 'help'
      • 2.1.1 auth token 提示:authentication token does not match ~/.emulator_console_auth_token
  • 3.其他命令

想做一个自动提取短信的功能,所以需要频繁的使用到收到短信的功能。

1. 通过 telnet 与模拟器通信

打开终端,输入: telnet localhost 5554
localhost : 本机地址
5554: 模拟器端口号
成功后提示:

Android Console: Authentication required
Android Console: type ‘auth <auth_token>’ to authenticate
Android Console: you can find your <auth_token> in
‘C:\Users\Administrator.emulator_console_auth_token’
OK

1.1 无法使用telnet

在cmd中使用telnet,提示:

‘telnet‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。

在windows中打开设置→应用→应用和功能→程序和功能(在最下方)→启动或关闭Windows功能(在左侧)→勾选Telnet客户端。

2.发送短信

命令 sms send <phone_number> <message>
例:sms send 10086 hello world
模拟器收到 10086 发来的内容为 hello world 的短信。

2.1 提示:KO: unknown command, try ‘help’

原因:未验证auth token
解决:根据刚链接telnet后的提示,可以知道验证token的命令是auth <auth token>,auth token 存放在 C:\Users\<Administrator>\.emulator_console_auth_token,用记事本等工具打开,就可以得到token。

例:auth LblHpxTfTOgRk0vI

2.1.1 auth token 提示:authentication token does not match ~/.emulator_console_auth_token

原因:获取到的token不正确。猜测可能是由于有多个模拟器存在,token仅对应其中某一个模拟器。
解决:删除全部模拟器,删除.emulator_console_auth_token文件。重新创建一个模拟器,此时会重新生成.emulator_console_auth_token文件。

3.其他命令

  1. gsm
    打电话: gsm call 10086
    模拟10086给你的模拟器打电话。
    挂断电话:gsm cancel 10086
    模拟挂掉10086的来电
  2. geo
    模拟发送gps信号
    geo fix 经度 纬度
    即相当于将手机移动到指定的经纬度

本文标签: 模拟器发短信