Search code examples
androidshelladb

How to pass the new line on ADB


I would like to be able to send a SMS from my Android phone while it's connected to my computer using the following ADB commands so i refered this link. send a SMS from my Android phone

adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY \n GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22

adb shell input keyevent 66

Its working fine for me so when I started testing it, I can send characters,white spaces,special characters but not the new line. Say like I had 2 lines of text when I tried to pass, first line characters were sent but not the second line ones. So I want to know how to send the many lines through adb. Even I tried all escape sequence characters but still I couldn't pass. So anyone can tell me how to solve this .. Thanks in advance.


Solution

  • This is reported to work:

    adb shell "NL=$'\n' ; am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body \"SMS BODY ${NL} GOES HERE\" --ez exit_on_sent true"