I've been trying to convert a working Android Studio application to a library. I'm having difficulty figuring out how to convert the section of code that displays the MediaRouterButton into the library. The findViewByID is the real sticking point.
B4X:
private MediaRouter mMediaRouter;
private MediaRouteSelector mMediaRouteSelector;
private MediaRouter.Callback mMediaRouterCallback;
private MediaRouteButton mMediaRouteButton;
private CastDevice mSelectedDevice;
private int mRouteCount = 0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_router_button);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
// Create a MediaRouteSelector for the type of routes your app supports
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build();
// Create a MediaRouter callback for discovery events
mMediaRouterCallback = new MyMediaRouterCallback();
// Set the MediaRouteButton selector for device discovery.
mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mMediaRouteButton.setVisibility(View.VISIBLE);
}