我正在使用Cast Companion Library版本2.7.0,我将很快更新到最新版本(2.7.4);) 我的问题是,在点击投射菜单项时,我无法得到通知。
我的代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = castManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.media_route_menu_item) {
Log.d(TAG, "[ onOptionsItemSelected ] Chromecast connect action");
return true;
}
return super.onOptiotemSelected(item);
}
我已经测试过添加了一个MenuItemClickListener,但没有运气
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = castManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
mediaRouteMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Log.d(TAG, "[ onMenuItemClicked ] Chromecast connect");
return true;
}
});
return true;
}
由于