0

When multiple music applications installed in android phone, When I click on Play/Pause button in one music application using adb command. It is clicking on some other music application in background and playing the music. How to resolve this?

I used below adb commands to click on Play/Pause button.

adb shell input keyevent 85

Jagan777
  • 1
  • 1
  • 1

2 Answers2

0

Hi probably you miss this How can I play a mp3 file via adb command with google play music on android kitkat 4.4.4?

To play

adb shell input keyevent 126

To stop

adb shell input keyevent 127

KNewman Liuu
  • 136
  • 1
  • 5
  • (adb shell input keyevent 126) is working for android 4.0 version but not above 4.0. Not sure why it is not working. – Jagan777 Jul 23 '19 at 13:04
  • My phone version is 5.1, but it works.Have you seen this? https://developer.android.com/reference/android/view/KeyEvent – KNewman Liuu Jul 24 '19 at 01:54
  • I try this, and this work https://stackoverflow.com/questions/17829606/android-adb-stop-application-command-like-force-stop-for-non-rooted-device adb shell am force-stop – KNewman Liuu Jul 24 '19 at 05:57
  • Actually, I am working on 2 music applications which I have to test the scenarios: 1) to launch Google application -----> first play the song & Pause the song ---------> closing the application. 2) to launch Samsung application-----> Play song After launching the samsung application When I give keyevent 85 or 126, it is playing the first music applications song which is google music. But I want the song to play/pause in samsung which is foreground application. how to handle when two application need to launch and play song one after the other in Android 9.0? – Jagan777 Jul 24 '19 at 06:00
  • Even after force-stop it is not working. Force-stop is working in 4.4.4 version but not on Android 9.0. Any other command works here for Android version 9.0? – Jagan777 Jul 24 '19 at 06:57
0

To pause/play for both audio and video we can use both,

  1. adb shell input keyevent 126

  2. adb shell input keyevent 127

These are verified for Android 9+ devices.