Single Activity: Why, When, and How (Android Dev Summit '18)

[Music] hi everyone thanks for joining me my name is Ian Lake I am a developer on the Android team and I work on quite a few projects but most notably the

navigation architecture component as well as fragments as well as some of our new libraries like the Android X activity artifact and loaders and today I want to talk to you about single activity why when and how and really try and share some of the best practices from the Android team and from the architecture component team on what actually is going on in this world there's been a lot of questions way back from 2014 16 and even here in 2018 so we're here today to kind of talk over all of those wonderful things that make up what our activities so activities are really a component at the android level so they're at the same level as content providers broadcast receivers and services and they're registered in your Android manifests and really they are the UI facing pieces of your app right so when the android framework goes to start your application from launcher icon or an app shortcut or what you see when you're doing multi window those are all activities right so they really are kind of the entry point into your apps UI right when the user goes to launch your app they're launching an activity and we had a very interesting quote from Dianne Hackborn back in 2016 that once we've gotten into this entry point to your UI we really don't care how you organize the flow inside 2016 and I think it was controversial I guess in 2016 maybe we'll just say it had 77 comments on Google+ all right so a lot of people were really enthusiastic about this post but really like what what does it mean right like well what I think it means is that the framework shouldn't care the framework shouldn't care about your applications architecture right it needs to provide the hooks needed for the android framework to start your application but you should probably care about the architecture if you're out that's why you're all here today and I love having you here so the biggest problem is that you really don't know what an activity is actually going to do so what's the default animation for an activity well it depends depends on the version of Android what manufacturer you're on and even what seems they've the user has selected right so similarly we had property animations that were added in API 11 and they're much superior to view animations and the thing is is that while these new things become possible on new versions of Android they're not always applied to everything and things like activities they don't support property animations at all even today and even if we were to add them in the next version of Android maybe the letter after P we wouldn't be able to back port them because they're part of the framework right so thinking about all these things it's like well okay what what should an activity be used for right well why why do we even have activities they're useful as this entry point but then beyond that you're in your realm right you're in your realm of what your app needs to do and you don't necessarily need to rely on activities being the thing that you have to work with so let's take an example here we have some code like this we're calling start activity and we have to use activity compat because we want to a shared element transition alright so great our intent and then we say oh we want to have this one element shared well what API does actually work on well it depends on what you mean by work right it technically launches an activity that's true but it's only actually going to do a shared element transition on newer devices API 21 plus and really how many compactions do we need in our life it technically works you're saving some API checks but really this isn't the prettiest code to look at and similarly are there any hidden gotchas right if you are testing this on the latest version of Android if you test it on an older version of Android are you actually going to get the same experience well in this example I actually ran into this and I was like oh like well things are fading in and out and like sure I chose fade but it turns out you need to exclude things like the status bar a navigation bar otherwise still flicker and I was like well okay well that's fun I wouldn't have ever known that unless I tried it once and I tried it on a whole bunch of different devices and turns out on some devices it's totally fine and other devices not so much so there's a lot of little hidden gotchas here that you can't actually control or rely on in your app another example where we have multiple activities right and really each activity is kind of its own component in your app right so if you have two activities and you want to share data between them well there's not really a scope for that there is a scope for that but it's called your application scope it's the same scope that's shared by services and everything else in your app but you really want kind of a shared scope that's just within a couple of components so this is a structure that Android provides but it's maybe not the one you actually want to use so what you actually want is you want to build the layering you actually need so in this case we can have multiple things multiple destinations within an activity right and share in across each of these destinations by using the activity scope as an actual useful element now so for example you could have a shared view element or view model that both destinations talk to so one destination could put data in and the other one could observe changes to that data right you don't need to work at the application scope level for this to work so I mention this for a destination so what is a destination well really it's just a subsection of your UI

https://edgarqvzt.bloggersdelight.dk/2020/03/29/best-kodi-addon-2018-for-movies-tv-shows/
https://5e80b8910c5ea.site123.me/#section-5e80b959e5d8d
https://www.storeboard.com/blogs/general/best-kodi-addon-2018-for-movies-tv-shows/2232324
https://augustmcxy596.skyrock.com/3331338092-Best-Kodi-Addon-2018-For-Movies-TV-Shows.html
http://andresfgpx271.iamarrows.com/best-kodi-addon-2018-for-movies-tv-shows
http://chancernfh155.jigsy.com/entries/general/best-kodi-addon-2018-for-movies-tv-shows
http://judahfhzx584.yousher.com/best-kodi-addon-2018-for-movies-tv-shows
https://b3.zcubes.com/v.aspx?mid=3464799&title=best-kodi-addon-2018-for-movies-tv-shows
http://andersonrpvl780.huicopper.com/best-kodi-addon-2018-for-movies-tv-shows
http://e6bttpl260.nation2.com/best-kodi-addon-2018-for-movies-tv-shows
http://the-master-blog-6474.223353.n8.nabble.com/best-kodi-addon-2018-for-movies-tv-shows-tp2.html
http://andresljsu595.nikehyperchasesp.com/best-kodi-addon-2018-for-movies-tv-shows
http://troyyair811.canalblog.com/archives/2020/03/29/38144996.html
http://rowanltgq683.unblog.fr/2020/03/29/best-kodi-addon-2018-for-movies-tv-shows/
http://johnathanvsud698.institutoalvorada.org/best-kodi-addon-2018-for-movies-tv-shows
http://waylonnfch506.fotosdefrases.com/best-kodi-addon-2018-for-movies-tv-shows
http://beauqcnu119.zoninrewards.com/best-kodi-addon-2018-for-movies-tv-shows
http://messiahyhpc318.image-perth.org/best-kodi-addon-2018-for-movies-tv-shows
http://edgarlxor873.lowescouponn.com/best-kodi-addon-2018-for-movies-tv-shows
http://remingtonlqbi945.lucialpiazzale.com/best-kodi-addon-2018-for-movies-tv-shows
http://lorenzorunr590.bearsfanteamshop.com/best-kodi-addon-2018-for-movies-tv-shows
http://claytonbjiu362.cavandoragh.org/best-kodi-addon-2018-for-movies-tv-shows
http://remingtonakjg375.raidersfanteamshop.com/best-kodi-addon-2018-for-movies-tv-shows
http://andersonjrna917.tearosediner.net/best-kodi-addon-2018-for-movies-tv-shows
http://mariozcog039.theglensecret.com/best-kodi-addon-2018-for-movies-tv-shows
http://simonlcoe567.timeforchangecounselling.com/best-kodi-addon-2018-for-movies-tv-shows
http://paxtonkiet679.trexgame.net/best-kodi-addon-2018-for-movies-tv-shows
http://emilianoiran993.westbluestudio.com/best-kodi-addon-2018-for-movies-tv-shows
http://alexishtya067.almoheet-travel.com/best-kodi-addon-2018-for-movies-tv-shows
http://holdenigup439.theburnward.com/best-kodi-addon-2018-for-movies-tv-shows
https://d4utely078.wixsite.com/dallasmdbq918/post/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc
https://zanerecd621.hatenablog.com/entry/2020/03/29/220540
https://www.liveinternet.ru/users/d9xijwp978/post468580634//
https://elliotthsku962.wordpress.com/2020/03/29/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc/
https://www.evernote.com/shard/s481/sh/7f918c21-737b-d140-1aed-0be6b173b126/ab3ca11680cdefe3c2edabf6022d1e7b
https://diigo.com/0h5aww
http://edgarccho649.simplesite.com/445529645
https://telegra.ph/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc-03-29
https://marcoczer464.tumblr.com/post/613907517712564224/amazon-fire-tv-stick-4k-with-alexa-voice-remote
http://judahgcjn582.bravesites.com/entries/general/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc
https://www.smore.com/8cure-amazon-fire-tv-stick-4k-with-alexa
https://andersonnyoq486.edublogs.org/2020/03/29/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc/
http://waylondnnp814.xtgem.com/amazon%20fire%20tv%20stick%204k%20with%20alexa%20voice%20remote%20and%20vouc
http://daltoniaid634.wpsuo.com/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc
https://penzu.com/p/e31ac2bd
https://stephenzpgn.bloggersdelight.dk/2020/03/29/amazon-fire-tv-stick-4k-with-alexa-voice-remote-and-vouc/
https://5e806a078975f.site123.me/#section-5e806ad16c6fc

Comments

Popular posts from this blog