You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过ADB命令发送包含多行内容的短信

可行实现方法

你之前尝试失败的核心原因是换行符需要通过两层转义校验:本地运行adb的Shell环境、Android设备端的Shell环境,直接写\n只会被识别为普通字面量,不会被解析为换行符。

方案1:Linux/macOS/WSL环境(Bash/Zsh可用)

使用ANSI-C风格引号$'...'包裹短信内容,本地Shell会自动将引号内的\n转换为真实换行符再传递给设备:

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+目标手机号" s16 "null" s16 $'This is line 1 of the SMS\nThis is line 2 of the SMS\nAnd this is line 3' s16 "null" s16 "null"

方案2:全平台通用方案

先将带换行的短信内容存入变量,再传入adb命令,避免不同Shell的转义差异:

Linux/macOS/WSL写法:

# 构造带换行的短信内容
SMS_CONTENT=$(printf "This is line 1 of the SMS\nThis is line 2 of the SMS\nAnd this is line 3")
# 执行发送命令
adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+目标手机号" s16 "null" s16 "$SMS_CONTENT" s16 "null" s16 "null"

Windows PowerShell写法:

# 构造带换行的短信内容,PowerShell中换行符为`n
$smsContent = "This is line 1 of the SMS`nThis is line 2 of the SMS`nAnd this is line 3"
# 执行发送命令,额外嵌套一层双引号避免换行被截断
adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+目标手机号" s16 "null" s16 "`"$smsContent`"" s16 "null" s16 "null"

内容的提问来源于stack exchange,提问作者Kian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 21:27:03