public class MusicService extends Service {
private String Sring;
public MusicService() {
}
static boolean isplay;
MediaPlayer player;
static Map<String,Integer> date = new HashMap<String,Integer>();
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!player.isPlaying()) {
player.start();
isplay = player.isPlaying();
}
date.put("bird",R.raw.bird);
date.put("chimes",R.raw.chimes);
date.put("cock",R.raw.cock);
date.put("cuckoo",R.raw.cuckoo);
date.put("notify",R.raw.notify);
date.put("ringout",R.raw.ringout);
date.put("water",R.raw.water);
Sring=intent.getStringExtra("Sring");//這算是收到了引數嗎?
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
player = MediaPlayer.create(this,date.get(Sring));
}
@Override
public void onDestroy() {
player.stop();
isplay = player.isPlaying();
player.release();
super.onDestroy();
}
}
public class MusicService extends Service {
private String Sring;
public MusicService() {
}
static boolean isplay;
MediaPlayer player;
static Map<String,Integer> date = new HashMap<String,Integer>();
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!player.isPlaying()) {
player.start();
isplay = player.isPlaying();
}
date.put("bird",R.raw.bird);
date.put("chimes",R.raw.chimes);
date.put("cock",R.raw.cock);
date.put("cuckoo",R.raw.cuckoo);
date.put("notify",R.raw.notify);
date.put("ringout",R.raw.ringout);
date.put("water",R.raw.water);
Sring=intent.getStringExtra("Sring");//這算是收到了引數嗎?
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
player = MediaPlayer.create(this,date.get(Sring));
}
@Override
public void onDestroy() {
player.stop();
isplay = player.isPlaying();
player.release();
super.onDestroy();
}
}
報錯: Binary XML file line #0: Binary XML file line #0: Error inflating class xxx.AutoFitTextureView 解決: <com.example.testy2.AutoFitTextureView android: ......