0

`mediaRouter = MediaRouter.getInstance(getApplicationContext()); mediaRouteButton = findViewById(R.id.media_route_button);

    MediaRouteSelector mediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
            .build();

    mediaRouteButton.setRouteSelector(mediaRouteSelector);
    mediaRouter.addCallback(mediaRouteSelector, mediaRouterCallback);
}

private final Callback mediaRouterCallback = new Callback() {
    @Override
    public void onRouteAdded(MediaRouter router, RouteInfo route) {
        // Handle route added (device discovered)
        // You can get information about the discovered device from the 'route' parameter
        String deviceName = route.getName();
        String deviceId = route.getId();
        Log.d("MediaRouterCallback", "onRouteAdded - Name: " + route.getName() + ", ID: " + route.getId());
        if(mediaRouter.getRoutes().size() >= 1) {
            mediaRouter.selectRoute(mediaRouter.getRoutes().get(0));
            Log.d("MediaRouterCallback", "new " );

        }
        // Handle device information as needed
    }`

i am trying to discover all casting/wireless device on same wifi network with the helpof media router but it only discover onRouteAdded - Name: Phone, ID: DEFAULT_ROUTE this.

0