Sunday 15 January 2012

Android adb shell command to play sound from the command line -



Android adb shell command to play sound from the command line -

i have set of rooted android devices can access through adb on tcp/ip. trying identify specific 1 playing sound command line (one of .ogg files /system/media/audio).

i know build app feels overkill utilize apk, , i'm hoping there more native way. know how start intents command line.

things have tried :

investigated using service phone call media.player not find useful reference syntax. can see dumpsys media.player references awesomeplayer couln't going. tried find compiled version of "/system/bin/media" android source code, missing device, without luck far. tried build command line java app phone call android.media.mediaplayer dalvikvm knowledge of android , java limited (class compiled complained missing dependencies @ runtime)

any ideas?

after trial , error, reply working me.

based on other threads, found next java code bare minimum play sound through speaker. mediaplayer class seems 1 play no user interaction, others need real activity context...

class="lang-java prettyprint-override">public class beep { public static void main(string[] a) { mediaplayer mp = new mediaplayer(); seek { mp.setdatasource("/system/media/audio/alarms/ticktac.ogg"); mp.prepare(); mp.start(); } grab (ioexception e) { log.w("beep", "ioexception", e); } }

(actual working illustration here)

this must compiled dex file, linked android.jar, , can run adb shell command line using app_process (not dalvikvm) :

class="lang-sh prettyprint-override">export classpath=./beep.dex app_process /system/bin beep /system/media/audio/ringtones/beep-beep.ogg

it not one-liner hoping needed...

android adb

No comments:

Post a Comment