[MUSIC PLAYING]
CHET HAASE: Hi, I'm Chet Haase from the Android Developer
Relations team.
Welcome to "Now in Android," the second video
and hopefully podcast episode in this ongoing series.
Once again, I'll mention that I write the series of articles
called Now in Android on Medium, and I'm basically
trying to summarize that in video form
and audio form for people to consume it in other forms
instead.
So choose the way you want to get it and go
get the content wherever you'd like, including here.
So let's get on with this show.
So first of all, I'd like to talk
about the AndroidX releases that happened recently.
So as I came up to writing the article,
drafting the article this week, I thought, you know,
not much going on.
It must be the holidays.
There was like a couple of releases
that were worth calling out, a couple of RCs,
and that was about it.
And then January 22, which is yesterday
according to when I'm recording this, all of these releases
hit.
Apparently, they were just waiting for me
to finish the draft, and then they released everything.
So a lot of things came out, including a lot of library
versions that went stable.
So a few of those are Lifecycle-Viewmodel-Savedstate.
So this is an interesting one.
It allows you to associate a ViewModel with saved state.
So you already have the capability with ViewModel
to handle configuration changes.
Wouldn't it be nice if you could access the saved state approach
without going through all those manual overrides in the code
that you need to write to sort of retrieve the information so
that your activity restarts with the appropriate state
that it ended with during the configuration change?
So this makes that whole process a lot easier
with the SavedStateHandle class.
Also Fragment 1.2.0 went stable.
This brings in FragmentContainerView
as the container that you should use for all of your fragments.
It also integrates with Lifecycle-Viewmodel-Savedstate,
that thing I was just talking about above.
And it fixes some timing issues that
have to do with onDestroyView being
called when there are animations and transitions running.
Lifecycle 2.2 provides better integration with coroutines.
Navigation 2.2 provides navigation graph-scoped
Lifecycles and SavedState with the new NavBackStackEntry.
It also has query parameter support
for deep links and improved animations support overall.
And finally, coming stable recently with WorkManager 2.3.
This has a couple of methods that
are interesting-- setProgress and setForeground APIs.
These allow you to communicate progress
as a worker is running, and also potentially launch a foreground
service if that's the right thing
to do to finish something that you're in the middle of
and really needs to complete.
Also going stable recently were some more minor releases--
Activity 1.1, SQLite 2.1, and Transition 1.3.
There were also a few alpha libraries
that came out recently, including
Browser 1.3 went alpha.
So is the first release of that version, which has minor fixes
and features.
And Heifwriter 1.1--
Heif, Hefwriter-- Hef.
You know, it's about image file formats,
so maybe we're supposed to pronounce it "jiff."
I don't know.
I'm going to call it Heifwriter.
So this library provides the capability
to write HEIF images, which are High Efficiency Image Format
images.
So given images, given the data for the images, one or more
of those, it can write in this new format.
And so that was the original library's purpose.
This 1.1 release offers some minor features and fixes
on top of that.
Second up today, we'll talk about Android Studio.
So there's a couple of Preview releases
that are worth checking out.
So Android Studio has stable release out there 3.5.
And maybe that's the one that you're
using for production development,
but maybe you're also interested in checking out
some of the new capabilities in the Preview releases,
sort of get them new or play around with them,
give us feedback, and integrate them as it makes sense for you,
depending on what you're working on.
So Android 3.6 just went RC, which
means this thing must be going stable sometime soon.
Some of the new, interesting features in there
that are worth checking out are the split-view editor.
So this allows you-- before, you could
take a look at either the text or the design of your layout,
but now you can actually see them
side by side instead of having to toggle between them.
So you can use that.
You can get easier leak detection
with the memory profiler.
And you can also try out the new View Binding.
This is the capability that means
that you can avoid calling findViewById everywhere.
So it's sort of an easier way to access
and a type-safe way to access the IDs that are in your layout
files directly in code without actually needing
to manually load this thing or use one of the other approaches
out there, which have other overhead and issues associated
with them.
So View Binding is the new recommended way
to do this, so check that out if you
want to avoid all of that boilerplate code
that we all know and hate.
Android 4.0 is in beta right now.
And this has the MotionLayout visual editor.
So I think I talked about this one last time.
So if you've been using MotionLayout,
or have looked at that, or are interested in it,
it's a way of doing much richer layouts,
certainly much richer layout animations,
using ConstraintLayout and the subclass of it
called MotionLayout.
But before, you had to write the XML by hand, which
tended to be kind of tedious.
Now, there's a visual editor for it,
so you can use the design tool that it
was developed in concert with.
So that is worth checking out.
Also, 4.0 has support for Jetpack Compose, the new UI
toolkit that that team is working on.
It is pre-alpha, in development.
They're developing it in the open.
There were some talks about it at Android Dev Summit.
You can sort of see the overview there.
In fact, we just released a podcast on it
that I'll mention later.
But if you want to actually play around with Compose
and use the tutorial, then you'll
need access to the tool that supports it
with the appropriate Kotlin compiler that knows
what to do with this stuff.
So check out 4.0 for that.
You'll want to see the new enhanced Layout Inspector.
New capabilities there.
There's a new UI for CPU Profiler.
So we've had the CPU profiler for some time,
and it was certainly better than the original trace view
in terms of the UI and what you could do there,
but they've kept working on that, sort of fundamentally
redesigning the UI to make it easier to access
and to understand that information, which tends
to be kind of complicated.
There's also a new build speed visualizer.
This allows you to see where the time is going in the build.
So we're always working on build speed to make things better,
but at the same time, you're always
adding stuff to your project because that's
the way software goes, right?
So it's kind of nice to see whether the hiccups
and build speed are coming from new annotations
that you've added, a new library that you're pulling in.
Like, is there anything you can do on your side
to make sure that you're getting the best build speed possible?
So the visualizer is helpful for determining that.
Also, there's new templates for fragments.
So the templates that we used to have sort of ignored
the fragment space.
And at the same time, we're telling everybody,
you know what?
Single activity and fragment usage
is kind of the recommended way to write modern Android
applications.
So it was kind of hard to get there if you couldn't actually
start from a template. a
So now, we give you templates.
It sort of gets you out of the gate a lot faster.
So you can write these new single-activity models.
You can use fragments.
You can use navigation much easier from the start,
so check those out.
There's also a new Kotlin DSL for scripting your build file.
So if you wanted to use Kotlin everywhere, then wouldn't it
be nice if you could also use it for your build files?
Well, you'll need to use 4.0 to use that, so
that the editor actually understands
the syntax that you're using in those build files.
Third, we have a new article series
that Florina Muntenescu introduced
called Kotlin Vocabulary.
So this is on Medium.
And the first one of those articles is out.
It is called "Alter Type with Typealias."
So she talks about the typealias feature of the Kotlin language
and also talks about import aliases.
So if you think about it, typealias is essentially
equivalent to if you're coming from a C,
C++ native programming background,
it's equivalent to typedef.
You could think of it as sort of an alias for typedef.
It is also similar to the things that you
can do with import alias, basically
renaming things to make them more convenient or more
obvious in your code.
Sometimes, it's not necessarily the right approach
for what you're trying to do-- like are
you obscuring information instead
of making it more obvious?
Anyway, the article covers all of this stuff and more,
so check that out.
Also she is looking for ideas for future episodes
in this ongoing series.
So she has a Twitter thread that she posted looking for ideas,
so head over to Twitter and Florina's account there
to give her some ideas if you'd like some things explained
in the Kotlin language.
Also we have a new codelab that Wojtek Kalicinski introduced
called "Building a Kotlin Extensions Library."
So we have this extension stuff that we've
been doing called Android KTX, where
we introduce extensions to make Android APIs easier
to use by using this nice Kotlin extension language feature.
You can do this for your own code.
So you can have your own extension library, not just
ours.
And Wojtek takes you through, in his codelab, how to do that.
So you can create your own extensions,
create your own library.
Also, examples of how to use various Kotlin features,
like there's an example of converting an existing API that
uses asynchronous callbacks into one
that uses Kotlin coroutines and either
suspend functions or Flow.
Finally, there's some new podcast episodes out.
Normally, in this section of the article,
I talk about the new ADB episodes.
So "Android Developer Backstage" is the podcast
that I host along with Romain and Tor.
And we have a new one out called ADB 131,
so the 131st episode called "Jetpack Compose
and Declarative UIs."
We sat down with Adam Powell from the Android Toolkit team
and talked about Jetpack Compose, and also all
kinds of related stuff.
So the point of the podcast of ADB
is not to talk about how the API works, right?
You can get that from the reference documentation.
It's more how the platform works.
What's under the hood?
What is the thinking and the design
going into various decisions that we made?
How does this stuff integrate into what
you're using right now?
Just all of the surrounding material to help everybody
understand how Android works overall
and how we can all become better Android developers because it's
kind of important to understand the full stack, right?
So we talk with Adam about related things,
like declarative programming in general,
and then we got into some discussion
of what does it mean to be declarative because wasn't
XML declarative to begin with.
And you know, where is the logic and where
is the declarative stuff?
So there's this phrase we use, dynamic declarative.
You can learn what that means.
I did.
We talked about reacting to state changes, which
is one of the big things that a toolkit like this needs to do.
So if some state changes, wouldn't it
be nice if your UI code is notified,
so it can automatically react to that,
and then repaint the UI as appropriate?
We talked about data that flows through an application.
So again, if state changes somewhere,
how does that data actually get to where you need it?
And we also talked about Kotlin DSLs,
which is sort of at the heart of the syntax
that they use for this new composable stuff
that Jetpack Compose is all about.
Also, not just ADB exists out there for Android developers.
There is this podcast called "Fragmented," which maybe you
already listen to.
They're now at episode 187.
"Fragmented" podcast is hosted by Donn Felker and Kaushik
Gopal.
And recently, they had a couple of people from the Android team
on there, so Manuel Vivo and Sean McQuillan from my team--
from the Android Developer Relations team.
And they were talking about coroutines.
So check out that podcast for more stuff about Kotlin,
and Kotlin coroutines, and how all that stuff works.
And then finally, if you'd like to figure out
what the links are to all this stuff,
we're not going to embed them in the video.
That's really time consuming and hard
to click on when you're just listening to it anyway.
So head over to the article on Medium to check out the links,
and we'll put the link to that article in the video.
Or just go over to the Android developers
publication on Medium and look for it there.
Thanks for tuning in again, and I'll talk to you next time.
If you liked this video, go ahead and like and share,
and maybe even subscribe to the Android Developers channel,
then you'll get the content when we post it.
[MUSIC PLAYING]