0
我註冊的廣播接收機來接收「com.android.music.playstatechanged」和「com.android.music.musicservicecommand」爲什麼不能收到「com.android.music.musicservicecommand」?
public void registerMusicServiceCommandReceiver() {
if (mMusicCommandListener == null) {
mMusicCommandListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("com.android.music.playstatechanged")) {
Log.d(TAG, "Music play state changed");
}
if (action.equals("com.android.music.musicservicecommand")) {
String cmd = intent.getStringExtra("command");
Log.d(TAG, "Music Service command : "+cmd+ " received");
if (cmd != null && cmd.equals("play")) {
Log.d(TAG, "received music service cmd, play");
}
if (cmd != null && cmd.equals("pause")) {
Log.d(TAG, "received music service cmd, pause");
}
}
}
};
IntentFilter commandFilter = new IntentFilter();
commandFilter.addAction("com.android.music.musicservicecommand");
commandFilter.addAction("com.android.music.playstatechanged");
registerReceiver(mMusicCommandListener, commandFilter);
}
}
但我只能接收到的「com.android.music.playstatechanged」 ,不能收到「com.android.music.musicservicecommand」, 有人可以給個解釋嗎? Thx提前。