× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Play Music from a service

Arnav Gupta
Jan 23, 2016
<pre><code class="language-java">@Override public int onStartCommand(Intent intent, int flags, int startId) { String songName = intent.getStringExtra("songName"); int songResId = getResources().getIdentifier(songName, "raw", getPackageName()); MediaPlayer mediaPlayer = MediaPlayer.create(this, songResId); mediaPlayer.start(); return super.onStartCommand(intent, flags, startId); }</code></pre> <p> </p>
comments powered by Disqus