I have a cast button in a fragment that I'm initializing using the Cast SDK's built-in CastButtonFactory.setUpMediaRouteButton function. When I call it like this:
CastButtonFactory.setUpMediaRouteButton(getActivity().getApplicationContext(), viewBinding.contentButtonMediaroute);
it fails somehow and the button isn't clickable. When I switch it to this:
CastButtonFactory.setUpMediaRouteButton(getActivity().getApplicationContext(), getView().findViewById(R.id.content_button_mediaroute));
it works properly. From what I understand, viewBinding is supposed to be the better alternative to findViewById. Why isn't the first call working?