活动:
String id = "blabla";
Intent musicService = new Intent(this, MusicPlayerService.class);
musicService.putExtra("MUSIC_ID", id);
startService(musicService);
服务:
@Override
public int onStartCommand(Intent intent, int flags, int startId){
super.onStartCommand(intent, startId, startId);
Toast.makeText(getApplicationContext(), "Music Service Started", Toast.LENGTH_LONG).show();
Bundle extras = intent.getExtras();
String s = extras.getString("musicID");
Toast.makeText(getApplicationContext(), "service start" + s, Toast.LENGTH_LONG).show();
return START_STICKY;
}
祝酒词从不显示,并且活动中的意图/启动服务行被 100% 命中。
我究竟做错了什么?