Service won't start in android
<p>Hi!</p>

<p>I have a service that should be playing an audio file when it is started from an activity (by a click on the button). The problem is though, the service won't start when i click the required button in my activity.</p>

<p>Service class (with imports and some other methods omitted):</p>

<pre><code>public class ClockService extends Service {

    MediaPlayer myMediaPlayer;

    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onCreate() {
        myMediaPlayer = MediaPlayer.create(this, R.raw.audio);
        myMediaPlayer.setLooping(true);
    }

    @Override
    public void onStart(Intent intent, int startid) {
        myMediaPlayer.start();
    }
}
</code></pre>

<p>The activity it is called from: </p>

<pre><code>public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button startButton = (Button) findViewById(R.id.startButton);
        startButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                startService(new Intent(getBaseContext(), ClockService.class));
            }
        });
    }
}
</code></pre>

<p>I've struggled with it for an hour already, and i can't see what's wrong.</p>
