Friday, December 20, 2024

All the pieces it’s essential to find out about Google TV and Android TV OS

Over the previous yr, we’ve seen important progress of Android TV OS, reaching 220 million month-to-month lively units with a 47% year-over-year enhance. This unimaginable engagement wouldn’t be attainable with out our devoted developer group. A large thanks on your contributions.

We’re bringing Android 14 to TV! The subsequent era of Android supplies enhancements in efficiency, sustainability, accessibility, and multitasking that can assist you construct participating apps for TVs.

hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)

For extra particulars, seek the advice of the up to date Android TV app high quality tips and the Android 14 for TV launch notes.

Compose for TV

Compose for TV is now obtainable in 1.0.0-beta01. We’ve up to date the developer instruments in Android Studio to incorporate a brand new challenge wizard to offer you a operating begin with Compose for TV.

Listed here are just some methods Compose makes it simpler to construct apps for TV:

    • Devoted parts for TV apps. Discover these parts in our design information or in apply by utilizing our new TV Materials Catalog app. Because the earlier alpha launch, we’ve added lists, navigation, chips, and settings screens.
    • Improved enter assist and efficiency. We’ve labored arduous to handle focus points and make sure that the UI seems and animates easily.
    • Ease of implementation and in depth styling. Add parts to your app and customise them with minimal code.
    • Broad form-factor assist. Reuse enterprise logic out of your telephone, pill, or foldable app to render a TV UI with modifications that may be as small as merely including a ViewModel.

Beta01 makes two huge modifications from alpha10:

    • A number of parts have graduated from experimental.
    • The ImmersiveList composable has been faraway from the androidx-tv-material package deal.

Carousel and chip parts, similar to FilterChip, are nonetheless experimental, so that you’ll wish to maintain the @ExperimentalTvMaterial3Api annotation if you’re utilizing these parts in your app. For all different parts, now you can take away the @ExperimentalTvMaterial3Api annotation, since these APIs at the moment are obtainable in beta.

We heard your suggestions concerning the selection within the knowledge varieties that symbolize content material, which made it tough to design a part in such a means that it could lead to much less code. If you’re utilizing the ImmersiveList composable from the alpha launch, substitute it with a customized implementation of an immersive listing. Whereas ImmersiveList is not a part of Compose for TV, you may create an immersive listing with just some traces of code:

@Composable
enjoyable SampleImmersiveList() {
    val selectedMovie = bear in mind { mutableStateOf<Film?>(null) }


    // Container
    Field(
        modifier = Modifier
            .fillMaxWidth()
            .peak(400.dp)
    ) {
        // Background
        Field(
            modifier = Modifier
                .fillMaxWidth()
                .aspectRatio(20f / 7)
                .background(selectedMovie.background)
        ) {}


        // Rows
        LazyRow(
            modifier = Modifier.align(Alignment.BottomEnd),
            ...
        ) {
            objects(motion pictures) { film ->
                MyMovieCard(
                    modifier = Modifier
                        .onFocusChanged {
                            if (it.hasFocus) {
                                selectedMovie.worth = film
                            }
                        },
                    ...
                ) {}
            }
        }
    }
}

An entire snippet is accessible within the immersive listing pattern.

Additionally seek the advice of the great listing of modifications within the launch notes emigrate any renamed or moved parts.

Migrate from the Leanback UI toolkit

We advocate following our step-by-step migration information to change from Leanback to Compose for Android TV.

Assets

Whether or not you’re new to Compose or are within the technique of migrating to Compose already, our massive assortment of sources are right here that can assist you be taught greatest practices for constructing TV UIs with the fashionable Android improvement toolkit, Jetpack Compose:

Have interaction with the lively Android developer group on Stack Overflow for any bugs you encounter, or submit the bugs via our public bug tracker.

Thanks on your continued assist of Android TV OS. We will’t wait to see what you’ll do on Google TV with the Android 14 TV OS!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles