#1.注册
private void initData() {
// mReceiver=new MyReceiver();
// IntentFilter intentFilter=new IntentFilter();
// intentFilter.addAction(OPEN_AUDIO);
// registerReceiver(mReceiver,intentFilter);
EventBus.getDefault().register(this);
}
#2.订阅方法
@Subscribe(threadMode= ThreadMode.MAIN,priority = 0)
private void showData() {
showViewData();
checkPlaymode();
}
#3.发送消息
class MyOnPreparedListener implements MediaPlayer.OnPreparedListener {
@Override
public void onPrepared(MediaPlayer mp) {
//通知Activity来获取信息--广播
// notifyChange(OPEN_AUDIO);
EventBus.getDefault().post(mediaItem);
start();
}
}
#4.取消注册
@Override
protected void onDestroy() {
LogUtil.e("onDestroy。。。AudioPlayerActivity");
super.onDestroy();
unbindService(con);
EventBus.getDefault().unregister(this);
// if(mReceiver!=null){
// unregisterReceiver(mReceiver);
// }
}