lundi 4 mai 2015

android - cannot start an inner Service

I am having an application playing music. I would like to play it in background, I tried with AsyncTask but it did not work, then I decide to use Service instead. Because I can not pass delegate to Service, so I declare this Service inside main class and call startIntent to invoke it. I have declared in Manifest file but it still does not work. The following is my code

public class DetailFragment extends BaseFragment implements SeekBar.OnSeekBarChangeListener{
private MediaPlayer mMediaPlayer;
//write some codes here
.
.
.

//then declare my Service class public class AudioPlayerService extends Service { public AudioPlayerService() { } } }

It always say: java.lang.RuntimeException: Unable to instantiate service com.mycompany.fragments.DetailFragment$AudioPlayerService: java.lang.InstantiationException: can't instantiate class com.mycompany.fragments.DetailFragment$AudioPlayerService; no empty constructor

In Manifest.xml
"android:name=".fragments.DetailFragment$AudioPlayerService" android:enabled="true"

Can someone help me out on this case?

Aucun commentaire:

Enregistrer un commentaire