英文:
How to stop casting immediately on Android?
问题
I need to stop casting after the user enabled it inside my app.
The app listened to MediaRouter.Callback
as below:
private val mediaRouterCallback = object : MediaRouter.Callback() {
override fun onRouteChanged(router: MediaRouter?, route: RouteInfo?) {
super.onRouteChanged(router, route)
// notify observers that casting occurs
}
}
Now, in the observers, I need to stop casting immediately when the user should not use casting inside the app.
Let's suppose the code below is inside a Fragment and observes the casting event, so what would be the implementation code for stopCasting()
method, for example:
when (event) {
PreventCasting -> {
stopCasting()
}
}
英文:
I need to stop casting after the user enabled it inside my app.
The app listened to MediaRouter.Callback
as below:
private val mediaRouterCallback = object : MediaRouter.Callback() {
override fun onRouteChanged(router: MediaRouter?, route: RouteInfo?) {
super.onRouteChanged(router, route)
// notify observers that casting occurs
}
}
Now, in the observers, I need to stop casting immediately when the user should not use casting inside the app.
Let's suppose the code below is inside a Fragment and observes the casting event, so what would be the implementation code for stopCasting()
method, for example:
when (event) {
PreventCasting -> {
stopCasting()
}
}
答案1
得分: 1
如果你想停止投射,只需使用 castContext?.sessionManager?.endCurrentSession(true)
英文:
If you want to stop casting you only need to use castContext?.sessionManager?.endCurrentSession(true)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论