Note that there are some explanatory texts on larger screens.

plurals
  1. POMy service isn't getting called
    primarykey
    data
    text
    <p>I have a service which takes in an audio file and plays it with a media player this is how i call my service </p> <pre><code>private void playAudio(String url) throws Exception{ Intent music = new Intent(this,MusicService.class); music.putExtra("paths", path); startService(music); } </code></pre> <p>and this is my service </p> <pre><code> class MusicService extends Service implements OnCompletionListener { MediaPlayer mediaPlayer; String musicFile; @Override public void onCreate() { mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_LONG).show(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle e = intent.getExtras(); musicFile= e.getString("paths"); try { mediaPlayer.prepare(); mediaPlayer.setDataSource(musicFile); } catch (IllegalArgumentException i) { // TODO Auto-generated catch block i.printStackTrace(); } catch (IllegalStateException i) { // TODO Auto-generated catch block i.printStackTrace(); } catch (IOException i) { // TODO Auto-generated catch block i.printStackTrace(); } if (!mediaPlayer.isPlaying()) { mediaPlayer.start(); } return START_STICKY; } @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub } @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } } </code></pre> <p>The service is never getting executed the toast is never being made and the media player does not play the path. Thanks i advance for the help</p> <p>If i declare it in my manifest like this</p> <pre><code>&lt;service android:name=".MusicService" android:enabled="true"&gt;&lt;/service&gt; </code></pre> <p>I get a force close error</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload