我注意到的是,在我的应用程序中出现前景后,我得到了三个回调:
onRouteAdded -> onRouteRemoved -> onRouteAdded
首先我认为我的应用程序存在问题,但后来我尝试了这个示例: https://github.com/googlecast/MediaRouter-Cast-Button-android
观察日志:
04-30 12:08:49.940:E / TEST(857):onRouteAdded: 信息= {MediaRouter.RouteInfo UNIQUEID = com.google.android.gms:0246381b5bc93e0d714f6c1f73af5625, name = BraKrePet,description = Chromecast,enabled = true, connecting = false,playbackType = 1,playbackStream = -1,volumeHandling = 0, volume = 0,volumeMax = 20,presentationDisplayId = -1, 额外=捆绑[mParcelledData.dataSize = 568], providerPackageName = com.google.android.gms}
04-30 12:08:49.970:E / TEST(857):onRouteRemoved: 信息= {MediaRouter.RouteInfo UNIQUEID = com.google.android.gms:0246381b5bc93e0d714f6c1f73af5625, name = BraKrePet,description = Chromecast,enabled = true, connecting = false,playbackType = 1,playbackStream = -1,volumeHandling = 0, volume = 0,volumeMax = 20,presentationDisplayId = -1, 额外=捆绑[mParcelledData.dataSize = 568], providerPackageName = com.google.android.gms}
04-30 12:08:50.430:E / TEST(857):onRouteAdded: 信息= {MediaRouter.RouteInfo UNIQUEID = com.google.android.gms:0246381b5bc93e0d714f6c1f73af5625, name = BraKrePet,description = Chromecast,enabled = true, connecting = false,playbackType = 1,playbackStream = -1,volumeHandling = 0, volume = 0,volumeMax = 20,presentationDisplayId = -1, 额外=捆绑[mParcelledData.dataSize = 568], providerPackageName = com.google.android.gms}
正如你所看到的,它也在那里发生。它导致我的应用程序出现问题,因为我的chromecast按钮是
shown -> hidden -> shown
任何人都知道为什么会发生这种情况以及应该采取哪些措施来避免这种情况?