I'm facing a litte problem.
I'm trying to pass an playlist object to my media player service.
In its onStartCommand
, I'm getting a Nullpointer Exception
when trying to call extras.get()
or extras.getParcelable()
.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
L.d(this, "Service started");
Bundle extras = intent.getExtras();//Not null
if (extras == null) {
stopSelf();
return 0;
}
L.d(this, "Extras was " + (extras == null ? "null" : "not null"));
defaultPlaylist = extras.getParcelable("playlist");//Nullpointer
currentSongNumber = extras.getInt(INITIAL_SONG_NUMBER);//Nullpointer
registerReceiver(getApplicationContext());
new NotificationPlayerControl(getApplicationContext());
NotificationPlayerControl.update(defaultPlaylist.getSong(currentSongNumber));
return START_STICKY;
}
extras
is not null.
What is going on there?
Edit: it seems that the error occures when I´m trying to write my parcelable object to the Bundle. I excluded it and now it runs well.
Maybe the Stacktrace was just a bit misleading