I want to use YouTube player from YouTubeDataAPI v3
in Jetpack Compose. But it should be extended of YouTubeBaseActivity
. The main problem is that activity extended of YouTubeBaseActivity
haven't composable setContent { }
. Only setContentView()
. Should i create another activity, extended of YouTubeBaseActivity
and xml layout? Or there is another way to use it?
CodePudding user response:
YouTubeBaseActivity
extends the base Activity
directly, which do not implement proper extension function. But you can work around that by using YouTubePlayerFragment
. The first thing the documentation is mentioning is that while using this fragment you don't have to extend your activity from YouTubeBaseActivity
CodePudding user response:
You can create compose view manually. Documentation here shows how to do it with a fragment, but you can do the same with an activity - subclass it from YouTubeBaseActivity
, add this to your XML view:
<androidx.compose.ui.platform.ComposeView
android:id="@ id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Then you can set compose content to this view.