I'm trying to send text message (SMS) from my Android terminal app in background (sim 1 or 2).

I can send message in foreground using this command:

am start -a android.intent.action.SENDTO -d sms:121 --es sms_body "test text" --ez exit_on_sent true;
input keyevent 22;
input keyevent 66;

But this command don't work in background.

So, how can I send message in background from my terminal?
Note: Android version 6.0. Rooted device

  • With "terminal" you mean an app like Termux or do you mean adb? If it is an terminal app does it have the permission SEND_SMS?
    – Robert
    Feb 9, 2020 at 12:46
  • app like termux and permission set ok!
    – Rabib
    Feb 9, 2020 at 13:46

1 Answer 1


The syntax that appears to work as attested over at our sister site stackoverflow is and is explains in detail:

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+1234567890" s16 "null" s16 "Hey\ you\ !" s16 "null" s16 "null"

"Isms method number (5 and 7 above) may change with the android version . Read full explanation to understand it."

  • It's not working. just display Result: Parsel(00000000, '....')
    – Rabib
    Feb 9, 2020 at 13:50
  • Firstly, you need to get the actual Service/package name for the service you are trying to call. You can get a list of Your devices Services by throwing the command: adb shell dumpsys -l. Look, for the Service'(s) with mms it will have a syntax of something com.whatevs mms.service. located use that in your command instead of just coping and pasting. Also inform me of the actual name and I will edit the answer. Lastly, reading the extremely detailed answer by @Taknok expailing the what's going on the subid is could be wrong too. Feb 9, 2020 at 17:09
  • In my terminal dumpsys -l show nothing. But if I run service list it's showing imms com.android.internal.telephony.IMms and another one isms.
    – Rabib
    Feb 9, 2020 at 17:30
  • Try both but first try the isms one just because that's the command your throwing. If that is a no go then try the Imms one. Also if you can look at the manifest you can most likely get the subid along with the service you need to utilize to send an SMS. Feb 9, 2020 at 20:28
  • also not working. However I build an apk for solving my problem. Thank you for your answer.
    – Rabib
    Feb 10, 2020 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .