CastCompanionLibrary并且不扩展ActionBarActivity [英] CastCompanionLibrary and Not Extending ActionBarActivity
问题描述
我们的应用程序仅针对14级及以上的API,因此我们不会扩展 ActionBarActivity
或使用任何兼容性库。
Our application is only targeted for API level 14 and above, and therefore we are not extending ActionBarActivity
or using any of the compatibility libraries.
是否仍然可以使用 CastCompanionLibrary
,因为它似乎假定人们正在使用compat库并扩展 ActionBarActivity
?
Is it still possible to use the CastCompanionLibrary
, as it seems to assume that one is using the compat libraries and extending ActionBarActivity
?
谢谢
推荐答案
答案是不。如果要使用Cast功能,则需要具有v7支持库中的媒体路由器(Android框架中的MediaRouter本身不足/在Cast中未使用)。支持v7的媒体路由器库取决于支持v7的appcompat库。简而言之,无论您使用哪种api级别,如果要使用Cast SDK,都需要在项目中提供这两个支持库。然后,要显示投射图标,您可以有几种选择。对于其中之一,您的活动必须扩展ActionBarActivity(CCL支持此功能),对于MediaRouterButton方法,必须扩展FragmentActivity(我可以考虑将对此功能的支持添加到CCL中)。如果您只是在使用活动,但需要两个支持库,则可以手动添加按钮并使该按钮正常工作,CCL不能处理其他情况。
The answer is no. If you want to use Cast functionality, you need to have media router from v7-support library (the MediaRouter in the Android framework itself is not adequate/not used in cast). The v7-support media router library depends on v7-support appcompat library. So in short, regardless of what api level you are using, you need to have those two support libraries present in your project if you want to use Cast SDK. Then to show a Cast icon, you have a few options; for one of them your activity has to extend ActionBarActivity (CCL supports this), and for the MediaRouterButton approach, it has to extend FragmentActivity (I may consider adding support for this to CCL). It is possible to manually add a button and make that work if you are just using an Activity but presence of the two support libraries is required, CCL doesn't handle these other cases.
更新:CCL现在支持FragmentActivity和MediaRouteButton。
Update: CCL now supports FragmentActivity and MediaRouteButton.
这篇关于CastCompanionLibrary并且不扩展ActionBarActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!