I'm testing some settings on a phone, and unfortunately the only control I have is through adb right now. My issue is that while I can start playback of a music file through the following command, I have no way of stopping it so I can perform the next iteration.

adb shell am start -a android.intent.action.View -d "file:///sdcard/Music/mediatest.mp3" -n "com.android.music/.MediaPlaybackActivity"

I don't know if it's possible to end the playback using another adb command, but it doesn't look like it to me - I see there are no Intents that seem to perform that function, nor any activities that are made to stop the media playback.

  • When you run the command, does the terminal "lock up" until the song has finished, or does it execute instantly and then return to the terminal prompt?
    – IQAndreas
    Commented May 16, 2015 at 7:19

2 Answers 2


Use KeyEvent to do the job.

adb shell input keyevent 85

85 corresponds to KEYCODE_MEDIA_PLAY_PAUSE. More keycodes can be found here or here.

Alternatively, if the activity featuring Play/Pause options is in foreground then you can do:

adb shell input touchscreen tap <X> <Y>

where <X> and <Y> are the coordinates of the tap that you would perform for Play/Pause using your fingers. See my answer here to know how to obtain them (step 1 and 2 under Instructions for Tasker and Xposed Additions).

Or, you can opt to completely kill the app using:

adb shell am force-stop <PKG_NAME>


Kitkat and above has the command media whose usage goes as,

adb shell media dispatch KEY

KEY can be play, pause, play-pause, mute, headsethook, stop, next, previous, rewind, record, fast-forword. (Source)

  • Though launching the app from scratch and sending different Mp3 location as data would also be easy thing to do.
    – Firelord
    Commented Aug 27, 2015 at 19:34

I stopped music player using "top" command inside adb shell and killing the process id of music app with superuser(ROOT) access.

  • 1
    More in depth instructions would make this a nice answer.
    – Peanut
    Commented Nov 2, 2013 at 2:33
  • @Peanut top shows the full package name on it, you don't need further explanations. Using keyevents and sending media stop is the way to go.
    – m3nda
    Commented Jan 12, 2018 at 21:43

You must log in to answer this question.

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