I want to connect to chromecast route programmatically, just as posted here: Is it possible to programmatically connect to a chromecast route?
When doing so (calling mMediaRouter.selectRoute(aRouteInfo)
), I get an exception java.lang.IllegalStateException: Null media projection manager
.
However, when selecting my chromecast receiver via the chromecast button from the popup list, then disconnecting and then calling mMediaRouter.selectRoute(aRouteInfo)
again, it works fine.
I assume I have to ask for some kind of permission before. Anyone knows what to do in this case?
The exception will be thrown in this line ...
mProjection = ((MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE)).getMediaProjection(permissionsResultCode, permissionsData);
... the parameter permissionData (Intent) seems to be incomplete.