googlecast / CastVideos-android

Reference Android Sender w/ Framework API: CastVideos-android application shows how to cast videos from an Android device that is fully compliant with the Cast Design Checklist.
Apache License 2.0
345 stars 183 forks source link

CastStateListner not getting called in fragment #92

Open wahdatjan opened 4 years ago

wahdatjan commented 4 years ago

CaststateListener not getting called in Fragment. i am calling it in onresume . when fragment starts nothing happen during onresume .But when app goes in background so onstop is being called then coming back to foreground onresume is being called , at that time listner works . ` @Override public void onResume() { super.onResume(); castContext.addCastStateListener(new CastStateListener() { @Override public void onCastStateChanged(int i) { if (i == CastState.NO_DEVICES_AVAILABLE){ mediaRouteButton.setVisibility(View.GONE); } else { mediaRouteButton.setVisibility(View.VISIBLE); }

            if (CastState.CONNECTED == i){
                EventTrackingManager.getEventTrackingManager(mContext).trackClickedItem(TrackingEvents.CHROMECAST_CONNECTED,null);
            }
        }
    });

}`