Droidcon NYC 2016 - Interprocess communication on Android

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right hello everyone i'm kevin barry i do nova launcher and i'm here to talk to you about inter-process communication so first i want to talk about watchers to nova launcher aw lots of people think that launchers is more than it is but they also think it's less than it is so really it's an activity but it responds to the home in sort of press the home button you get the launcher so it's it behaves like an activity like like all the activities you use them in normal apps the big difference is that it's running all the time which has a big impact on like like memory management's much more important for something that's always running and it's interacting with the system that like it's displayed all the icons on your your desktop and it gets that from the system it's displaying app widgets it gets that from the system ah so yeah that's that's what it the launcher is on I think that gives launcher developers kind of a unique view of Android and so I'm going to talk about the launcher view of inter-process communication so here's a rough graph of what Nova is doing so Nova has some help or apps we have a Tesla unread over here and noble enterprise over there so nova launcher itself is a free app but to get all the goodies you need to pay for it so that's you by Nova prime is a separate app and then no but can communicate with that find out that it's prime and unlock those features Tesla read which requires prime it gathers unread counts from different apps so that means it needs to be talking to these different apps or it needs to be you know having those apps updated or talk to the system to find what apps have unread counts and then it fades that back to nova and then the the bulk of the ross communication is nova talking to the system so that's odd and that's all of our apps are doing that that like when we're just later window on the screen that's IPC when we're starting to activity either our own or another that's IPC so there's there's a large amount of inter-process communication in every android app it's just normally we don't notice it and that's great because it's working when we do notice it is what it's not working questions um I'm not really done odd but I i think i'm going to present better if you guys ask me questions so feel free to interrupt like let me know what you want to know and we can talk about that but I have some more slides to it to give it overview so there's different types IPC aw so it's not like I work out I pc before Android heavily like you know I use it as much as you know any developer might happen to use it but it's so I don't really know the other methods well but you can do things like you can use the TCP service talking to someone who is using HTTP server on Android just to like send json to another process so that works on unix sockets which lets like if you used x windows that uses a eunuch socket--it's it looks kind of like a file but you can write stuff there another process can read that you can just read and write actual files like on android sometimes we will if you have multiple pressed in the same app you might use the shared preferences file and that's potentially dangerous but it can work you can have some communication there we're like vegan experian kill that sends a signal so like you can you know what when you get some signal you can do something maybe or even another file so yeah kind of those two methods or maybe you just have the signal you act on it but an Android we have intense so that's for broadcast activities and services and we have binders assume you all have used intense but let's talk about what's wrong with them so third party apps like if it's you know someone can feel it feels like hey you know be cool if we had this this api for nova launcher in my app what if we do it this way and it's almost always suggesting broadcasts and this because broadcasts are really easy to implement you you have on receive you take some action you have a son broadcast to trigger it the problem is that i it's it's almost always wrong you can't tell who sent that broadcast unless you actually say hey this was sent by me but anyone could lie or any apke liye and this isn't just protected from like malicious apps it's that sometimes a well-meaning app might just say hey you know if I tell Nova that I'm facebook and I can say hey I'm Facebook can you put on a red count of five on my icon and that's because this well-meaning at believes that Facebook has five on red counts but then facebook tells me hey by the way I have six on red counts now what should know but do it can't it does it you can't trust either of those sources and the user gets confused because something's wrong arm you can technically protect broadcasts with a permission but if you declare your own permission it's really unreliable if you're not a system app so like when you you know these in your manifest you can declare permissions if your installed first deal in that permission if someone else declares permission in their installed first day on it and so prior to I think it was marshmallow yaad they were both install so like your app declares his permission I install I think I own it but actually you own it you said anyone can have this I said only people their site only app signed with my signature can have it but you installed first so you win anyone can have this permission oh and I could check this but it's but even if I know it's broken what do i do I just break the API that's not good all right on marshmallow it's better and worse it's more secure if your app is already installed you deliver the permission my f1 installed but for your users that's awful they try to sell your app the place sources like air- 505 and they they're mad at you I so don't use third-party app permissions which means broadcasts have no security and I said you don't oh you don't know if we sending it sometimes you don't know who is listening I if you're saving the broadcast you can target it like just send it to this app or but if you're setting it you know it's a general API you have no way a seed who actually received so what our binders so binders are they were started I don't know if they actually used on BOS but they're started at be ink for future version of the OS then they moved to palm and then finally made their way to Android and this has been Dan half borns been working on it at all these places so if you see her talking about binders interprocess communication she can see him a little angry or something but she's basically always right so the trust tak born ah the idea is it gets object-oriented interprocess communication and so sometimes the binders in and reviews it's just like a token like you know I declare binder and I give it to you and now we both have this object and we know like you know if I go away you could see that I'm gone and you can trust that it's from me and you can verify the identity um but you could also have methods there they can be called or sometimes it's used like I'm calling a method for you in you and I'm going to send you a binder that you could call me back when you're done processing or something since they said yeah what process creates it sends it to another oh and the way we send it is right strong binder and now with the end by the prop the other process gets a binder proxy that implements the same binary interface um so right strong binder notice the strong here oh this means this is a strong reference to that binder so it's easy an interest memory leaks if you if you send a binder like an anonymous inner class binder part of your activity because you want to call back um now that service is holding on to your activity so keep that in mind when when working with these um but you can what you can do with the binders transact which that's the heart of it it's how you call methods on it you can also just check to see if it's still alive or you can get a call back when it's when the process is killing process is killed and so there's also a IDL so this is when you're when you have a balance service you can communicate over an AI dl interface so this is a it's a cleaner language to write these these kind of ugly methods but it's you write code as if okay I have this this interface as these methods it takes these arguments and then it creates the actual binary notation where it's calling binder transact on you can send primitives easily if you want to send any more complex object then you need to parcel it but and so it's a form of flat scene in it um yeah but and you can't you can parcel binders so you can be sending you can you know get a binder from someone and send it to someone else which actually like can be useful for sending callbacks that like let's say you know service okay Alice has some service and and she can give you a call back I've permission to talk to Alice um and so I can I can ask for this and she can call me back but really I don't care myself on then Bob he cares so but he doesn't permission of talk to Alice so he could talk to me and say hey can you ask alice this and what you're done call me back here and I can just tell Alice to call back Bob and I don't want gonna need to worry about it ah there's also content providers um so I actually really like content providers and I feel they're kind of underused um I don't like the default database implementation because it just feels like it's so much you know so much overhead if you just want to use the database in your own process and I don't don't use a content provider if you're just using one process it's it's a pain don't bother on but if you're doing inter-process communication they're really cool oh so they're basically already implemented aidl has a few simple methods insert query update delete and there's you know ball cancer and a few other things um but yeah it doesn't need to be a database i have i have several kind of providers one of them is like you know as few lines of code as kind of writer can be and it saw call it api provider and i just use it for custom commands and you can also provide file streams so really often and this is this has to change now and end but really often apps when they're communicating they're sending files in the form of you know a slash SD card path they're slightly better you know a file path um but really this is it's kind of like I've seen broadcasts as a bad method that you don't know who is going to read the file you have to get permission I've you know anyone that has right read SD card access has to be able to read it and likewise the receiver has to have SD card access so like Nova doesn't need to have SD card access necessarily but I always have to like prompt users that weird times because I get something back from one of your apps and it's it's a SD card path alright so I want to talk about when to use dif different methods so back to intense start activity is is really great when you can get away with it so I eat if you just want to send something off ah you know can you I sent it off and be done with that or send something off and get a result oh so like cropping a bitmap sending email picking a contact I use it in your own app makes perfect sense using if they're probably apps the main challenge is that you don't necessarily know like there's there's no way of verifying that they actually uphold their end of the deal so like they might say you know they they support a crop bitmap intent but actually once you call them they just show like a generic image picker and they never return anything to you there's not a way around that that's just kind of the nature of vanity ecosystem I start service likewise for start intent except it's for background tasks in theory you could use start activity to start a background task and in your own app that could work you can start an invisible activity that does whatever um it's weird don't do that unless you have a very weird use case but with third party apps would be much more dangerous that you know if you're trusting this is gonna be a physical activity and it's not it's very disruptive to the user by on one cool use of start service in a second process in your own app is Lee canary so if you have it usually connect it's really cool it's from square aw it helps you monitor memory leaks in in your app and so what it does is it kind of attached as a watcher it sees that this activity still around when it shouldn't when it likely shouldn't be ah and then it opens a new process that process can debug to your app gets a memory dump analyzes it and then post a notification saying hey I found this league and bind service so start service if you just want to start something but you're not going to get a result or you're not going to be able to you know keep interacting with it but in service lets you actually interact with it and that's when you have to use a IDL developers including myself or hasn't to use this just because it's it's a pain to deal with that like you're creating this aadl then like you know maybe under its to do doesn't sing seen it before so build in order to see you then you finally get it then you're you know return these objects and you're forgetting to unsubscribe you're leaking memory so it's into pain but it's it's needed for for certain things if you want to get callbacks in the middle or at the end and then content providers my my favorite when you want to add update or delete data and then when to abuse if you're going to view something don't abuse broadcasts abuse content providers ah you don't need to deal with a dl because it already has some methods there there's just simple methods but there's nothing telling you that you can see you know say inserts turn on flashlight like okay that's not that's not concept that you're providing or receiving but it's it's a command it'sit's abusing the API but it's really simple you can do it sometimes and the cool thing about this versus broadcasts is that you can actually check the identity by did I cat call get calling UID gives you the user idea of the process and you can use that to look up the package so you can verify who it is if you just want to allow you know your own apps or your friends apps or just so you can when you're debugging you're seeing you know something's going wrong and you're going to log what app it's coming from so you can try to reproduce yourself ah and you're in good company if you want to abuse content providers Google does it to Franco is saying hey Kevin can you help me I want a hacked pokemon go and I need to turn off the gps but but Google does it let me so in the settings provider if you try to just use it like you'd expect a set it's better to work and add GPS to the strongest stores there remove it it doesn't do anything and that's because they're not actually expecting they're not treated it as normal content in a database they treat it as a command where if you add plus GPS it'll turn on the GPS if you- gps it turns it off this is hacky it's it's bad on their recent than doing it for thread safety that if the string basically could say like you know GPS network cellular and they don't want the user turns off gps and turns off cellular these happen in different paths they don't want to actually turn run back on so they make it into a command so you can do this sometimes it's not good but it's better than broadcasts um I guess actually I talked about permission so third-party permissions don't don't work reliably well using binders you can use this binder clear Colleen identity I'm so like in 21 my my Nova API content provider suddenly API abuse um so one thing that I do there is and I don't know if any was actually using it now but like all sometimes app widgets get misconfigured and so app widgets are kind of weird sits a the app widget the user sees it is it's part of our goodies HD which is an example because I was working with them on that API so HD widgets it's a clock it shows some weather and they see it as all you know belong at HD widgets but really what happens is HD widgets tells the system here's what the which it looks like and the system tells the launcher here's how to display it so what they loaded is they wanted a way to delete the widget and they could you know they could replace the like hangouts did just you know hey this no longer works and that's a really bad experience they want to delete it from the launcher and so I did something where I have a tree widgets can connect to my account and provider i see i can check their they're buying her identity i see who they are and then i see there's a widget that they own and they want to delete it like okay there that I can trust them to delete the row which I'm not going with the delete widget from another app but for themselves but so when doing that is that what I want to talk to my own database my own content provider and you'd use binder clear calling identity and that's because otherwise the binder kind of remembers that it originally came from HD widgets even though it's in it's in my API content provider now it's going to go to my actual database aww and it's still no it's an identity and that does have permission to write to it so binder clear callin identity lets you replace the collar with your own and you can use that to kind of escalate permissions and but remember to restore it later or else things and get weird and so another cool thing with permissions is you can send you have activities and you don't want to export them for a reason and so this is an important part of Android is that you you want to be able to launch your own activities are providers or services ah and you don't you don't trust another app to interact with it and this might be an actual security issue you know if you're if it's bypassing your lock screen or something on but it's also I it's just the sanity thing that like if you're debugging you don't want to see crash reports from someone you know jumping into an activity that you're showing and I I'm guilty of this that if you guys do export activities Nova shows them to the users so like you know users can go in and Nova at a shortcut there's Nova has this activity shortcode where I show everything you asked for it and often these will crash what users kind of understand that because they reach it in you guys get the crash reports and that's sorry don't export them so or check the intense when you get it and if it's just you know generic blank intent it's from me or another launcher just you know do something else don't crash but so if you don't export the activity then you can use you can use binders your news inter-process communication to allow another app to still act exercise so like this is all like pending intense they can access your own not exported stuff even though the systems calling that back later on in android android and previews they had the launch of shortcut a and so that was cool that they had and they removed it but it looks like it might be coming back our but what they did is like you know a messaging app could have shortcuts to directly message someone and they don't want to reveal this to everyone on but they only trust it for themselves and that's that's understandable but they do want the launch of you'll access send so they can have a non exported activity and then this is all proxy through the system system checks is this the default launcher it trusts it and then it can launch these non exported activities um so file providers as i mentioned before like don't use SD card paths on you generally don't need to export file providers there are x if you're using one in a widget you really need to when there's no good way of doing that by uh generally you don't need to export these so then it's secure you could keep your files private no one randomly can access it but it can be accessed if you're you know certain other activity and giving it access or sending to the results or some other method of inter-process communication to transfer this this uri over it also means other apps don't need SD card permission which is this is this is getting to be more and more of an issue is that users aren't going to want to they don't want to accept you know parental permission other I happen other apps might not even declare it so like if you're sharing a photo with a photo manipulation app then maybe this sort of information app it's it's a modern app it doesn't even you know expect to use the ste card until it's writing to it so it doesn't have the permission it tries to read and it doesn't know to check your URI and guess that it's on that ste card and prompt the user preventively so it's just going to crash and users will blame your app and again you can check you can check the binder calling identity um so you could even return a different URI for different processes if you had some reason to and it can also be smart so I had a widget developer talking me so he does like this weather map widget and he wanted to she has to generate a bitmap for it's a very expensive process according to server like so he was getting a portrait landscape bitmap for each for each Versailles which I always and this was expensive and you know how many people actually use their phone and landscape at the lobster very few people on but the ones that do or the ones they're going to email and say hey this looks bad in landscape Susan you know is there a way that like Nova could tell me what mo what it's in if it's just objects from over that works but actually using a counter provider he doesn't need to do it just for know about he can see this information so he ended up doing is he has a counter provider and he has to image views in his widget well he has two views in his which and they both you know imageview portrait imagery landscape and in a portrait he has both of those views but one is just a regular viewer frame layout or something and the other sexual image view and then heat sense a Content your eye for them and then he can tell which which which view is X asking for us that he knows what dimensions to use so kind of relate space smart and this is this is really cool compared to just a normal file but there's transaction two large exception so how many of you have hit the transaction two large exception yeah all right it sucks on this is often it is your fault but it's not always and so it's very tempting if it's if it's not always your fault you get it you just think that's not my fault I'm not going to worry about it so do worry about it it probably is your fault but it's it's not necessarily there's a one mag limit for all the transactions on the system so if you're trying to transfer you know five bytes and I'm getting some you know some widget is sending me a bitmap through the binder transport and it's you know one Meg you get the UH transaction two large exception even though your city five bites you definitely didn't deserve it so this is unavoidable and it sucks your app might crash the other F might crash or worse things can suddenly break and you don't know it so this happens with widgets is uh I add state calendar widget he draws like these little lines of one color so it's you know a blue line it's one pixel high or something so he was using stepped in that for that what's the harm its I think he just stretches the bitmap so it's like 1 pixel x 1 pixel this you know no way this is causing in any issue um but he's getting this weird behavior where you know every once in a while for some users the widget no longer updates and it was an issue he was using said bitmap it's you know even though it should just be this tiny bit map maybe and some devices they were some issue it wasn't or maybe he's just hitting the generic transition to a large exception for because someone else was transferring a lot but he hit this issue and on the launcher one it crash his f1 it crash but the system would catch this exception and silently ignore it and block his widget from doing any further updates so this is really bad and you know ultimately you can't always avoid it but don't use sip set bitmap to try not to try to avoid it so don't send receive large amounts of data don't use set bitmap I never said that map remote views have set that map it's very tempting to use because the other is set image view URI and that's like you never use image view set URI directly but that's set image of you your eye it's a way of setting an image that's you know you can use a file provider you can use an SD card if path if you're not supporting to Android on yet and it's the launcher generally the launch is still loads this on the UI thread know of at Riesling on the back row threat if it can buy so it's still not great performance but neither set bitmap and this you're just sending a short string the URI so the actual IPC is over binders is minimal and then the launcher can go and read the file like it opens a normal file and that's when you're designing these api is remember to use small or paginate the results generally if you're gonna have a large data set use a content provider um but if you you know if you're going to return between you know 5 and 100 items may be using an array our list in a in a binder transaction makes sense just be cautious package manager is the the big one ah so this package manager should be a counter provider but it's not so if you want to get a list of all the Yoda list of all the apps on the device like your launcher you want to display this the user might have 500 apps they might have a thousand they might have four on you don't know and when you query you might get a transaction two large exception this is especially true like you're trying to get metadata for all the apps on the device that metadata can sometimes be very large amounts are so will you use a package failure just be very defensive that like you know if you're just queering email apps okay that's that's great on if you're if you're quitting your email apps an SMS SMS apps don't just query all on then filtering yourself just due to queries likewise if you if you want to query all apps like a launcher needs to do sometimes you just need to do to cry catch and so this is ugly but it's it's kind of a necessity ah if you catch it to shoot transaction two large exception sleep and try again you can do this in a loop to try five times you can just do it once ultimately at some point you don't want to just do it infinitely because then you're just using a lot of resources and it's it might just be crashing infinitely on you can also try catch maybe once you sleep and try again and then you can try a different approach so like the case of getting all the apps on the device normally you use query intent activities but if that's failing in the needs that you can get a list of just the packages installed get installed packages once you have the packages you can create each end of package meant query the package manager for each app individually to find out what activities it has that's much slower it's using more resources but it's using smaller individual transactions um so we talked about right strong binder before this is a strong reference to your binder so I you know when you send this binder over to another app as long as it holds onto the reference it's going to hold onto your binder and this is dangerous so don't trust a third probably have to do it right if using another another person's API when you send them a binder make sure it's a static binder not a inner class ah and if you need to access your own activity or something use a weak reference to do it but also don't trust yourself to do it right that like you don't you don't always control what version of the two apps the user has installed then even if you think you do like you know things can slip through on so I have there was a time when like Teslin red was holding on to nova launcher with a strong reference and so I was leaking because of that and then I fixed it in both places I fixed Nova so that I that can't happen again even if I mess up Teslin rep but likewise Teslin rad i fixed so that it's not going to do that so just you know be defensive remote views so their movies are weird on you've probably used them either notifications or an app widgets I kind of misconceptions or ammo view is a view and it's it's not it's a set of commands ah so remote views are commands you write the commands you send them over to the system the system sends them to the launcher the system UI for the notification and that inflates it and then it kind of execute these commands on it um so like for something like set text view all this is really I can see so tense that tech susan wrapper for such chair sequence that charge sequence is adding this action on these are all reflection actions too so I mean that most of them are reflections so that's that's also a performance problem I then leg boys for like scrolling widgets you know normally if you're making a list view you want to use a view holder you want it to be fast you don't have control over this anymore that like the launcher can't make a view holder because it doesn't know how you behave what you expect maybe you can't reuse views and the you can't tell us how to do it cuz rule because doesn't have an API for that so it's the movies are weird they also haven't been updated in a long time so like app widgets are it's an old API like honeycomb it got some you know new life and then it's kind of been static since then which is a shame so why use multiprocessing in the same map generally don't it's it's a pain it's it's not a good practice users also get confused if they see two processes like they want to know what you're doing why you're using more memory and two processes rather than just one um but you can actually use it to avoid out of memory errors so if you have few of something like a loan services run all the time and then sometimes you're going to launch into something where you're going to crop a bitmap or you know you're going to load data from another from a theme or an icon pack or something which are wallpapers um these can be very memory intensive and so if you have two processes each has their own cap on the memory and then also maybe your secondary process can go away also Android has a non compacting heat so what this means is that you know you start off you're just using one Meg of memory and that's great then you're going to show a bitmap you grow out you need five mix for this so now you're using six makes total then you're done with the bitmap you free it but you're still using six makes a memory it's just you have five empty Meg's available to you but not to other processes so once you blow you just you you're stuck at that value and so if your app is relatively short-lived it might not be too big of a deal but if its long-running or like if you have a slow startup time your users going to notice when you get kicked out of memory so using multiple processes to help you avoid this you're not going to grow the heap and your main process just in your secondary one which maybe you don't care about as much I also as I mentioned lead canary does it for debugging on firebase now also does this is the if using firebase crash reporting it has a second process where I like gathers the crash is Q's them up and sends them over to firebases app and the firebases app actually sends them up to Google or Google Play services as part of firebase um why is it at all you don't have a choice like ah most of the things here you're doing interact with the system in some ways so like when you're when you're drawing to the window on the screen there's a window tok and that's a binder and it's going to the system if you're you know interacting with any other app in some way you know just a share intent that's that's IPC um and permissions aw i guess i can already covered that but you can you can get around permissions I mean you know in a same manner you can get around permissions or you can protect yourself okay so no one did interrupt with questions but now any questions um so that was that's hustling red so that's my own app which helps but uh oh sure so he asked how did I find out that there was a memory leak between nova launcher and tesla and red and so so these are both I right both these apps so that that helps but it's I mean partially it comes from users reporting and it's hard to trust users users always you know complain and praise performance and it's you don't necessarily know what's true what's what they're imagining but it also just comes from you can use like in Android studio it has you can see the memory usage so you can see it growing over time the easiest way to detect a activity leak is to rotate your phone back and forth when you rotate your phone generally it's creating a new activity and so it should it's going to kind of spike a bit and you remember usage is going to spike a bit and then it should fall down as it does all the garbage collection if every time you rotate it's growing a little bit or even just when you first do a portrait or landscape in landscape to portrait if it's you know notably higher ten percent of twenty percent higher than what it was before you did the rotation then that's probably a memory leak and you can hit the like garbage collection block button in the android studio a couple times to make sure um and then once you suspect there's a memory leak you do a heap dump so again there's a button in Android studio you can analyze this using there is eclipsed memory analyzer tool and then it's a pain generally you look at the Dominator tree and so then it kind of shows like you know this activity has all these all these it has all this memory because of these these methods and these fields at holds on and instead until see or you can even search you can search for your activity and you see you know there's Mike tivities listed here twice and I should only have one instance of it on belleek canaries really good for helping automatically finally so highly recommend oh my so he was asking how to restart you how to share share user credentials or how to authenticate one out from another so you mean like in two different apps now two different process in the same app I mean so you could use the system account manager which has its own you know uses sundays don't like seeing an account listed there but that's kind of the Fisher way of doing it um first even kind of if you if you're not using that you'd have to kind of decide you want to have one app is the master or either app work so i'll assume that you want either have to work so like let's say you have you know you have a website that user logs into and maybe I'll says I have a forum on that web saying that can use the same login so user installs either at first then they're there long they log in then you want to share that each one could have a content provider on that kind of you know shares their settings on and including your auth token or whatever when you don't put a permission Allah content provider because third-party permissions don't work on but when you when someone connects that content provider you can verify the identity of it so you use binder die get calling you ID then you can use package manager to find all the packages installed with that uid a ninety percent of the time are you idea only has one package associated with it but there is that's another myth you can use I don't recommend it though you can have multiple you have different apps share you idea and then share state that way but don't do that it's messy so you query the UID and then you find the package then once you know the package you might in depending on how secure needs to be if it's a bank you really got to trust it see what want to verify the signature is the same if it's a more casual thing then maybe it's fine if a signature isn't the reason it could be initiative the signature is it is there like so it might take your your secondary apk and hack it maybe they're hacking it just so you know change the color use gray and they wanted pink but maybe they're hacking it to actually you know intercept the data or steal a data um so you can verify the signature to sign today PK if it's valid and then you can go ahead and do send the info over so I just lived like that for arm I have another app widget locker which more it was it's kind of an old rap but it let you customize the black screen and so I have some settings in Nova like when you're configured non-red counts um and basically you would always want to change them in nova launcher and and widgetlocker at the same time and so then each i guess actually no just widgetlocker has a kind of provider for its settings and so it trusts any app from me with my signature and then i can go in and I can just overwrite widgetlocker shared preferences from noble on shirts so that they match the settings there yes um you can't switch to using shared so he has to shared you sir I sure you do it you had shared user ID messy you can't switch to using shared uid if you started without it on an Android like they it would originally design Android they had a different plan for how it's going to work they don't exactly how it was but they mostly abandoned whatever that was and it's kind of just left there so like sometimes when you uninstall it doesn't clean up fa and it depends on the version but it might not clean up properly after itself you might get some issues like if you install one app and install the other then might you might have some subtle behavior difference and if you install them in the opposite order especially if they're uninstalling and reinstalling on so it's just the it's weird and then if you're using that to also share processes at that point like why not just make it one app so it depends on what your use cases but i would i'd avoid it unless you had a very very unique case yeah I'm sure so so that's I mean ah so yes I let's talk about the the Android life cycle when Android Michael your process so that's the don't don't count on it killing any predictable time that like it could happen any time um Android the the idea is that you shouldn't worry about when it could happen you should only worry that you preserve your data on and so then the user doesn't even need to know that like they they're using your f they switch to other that they come back and you your restored state perfectly you know it just took you a little bit longer so they don't notice in practice of course we do notice because we you know it's going to take us a while to load or sometimes we don't save state properly I'll Android try a as a list of priorities and so it prioritizes the launcher whatever the default launcher is it prioritizes apps that currently have a foreground service or are bound to having a foreground service that's a service that's a notification icon in the corner and it prioritizes the foreground activity and activities that are bound to the foreground activity our services are bound to the foreground activity and occasionally it prioritizes the like you have an activity on top of another activity and it might prioritize the one behind it if this activity is transparent and you sometimes you have transparent activities that's are opaque but the system thinks they're transparent so prioritize is that and now with multi window at prioritizes both of those on so uses these priorities and then it all looks at how much member you using and how when you were last used so if you're using a lot of memory and you weren't used recently they don't want to kill your process if you're just using a lot of memory but you were used recently but memories low it'll want to kill your process so the best way of avoiding getting killed is to not use much memory does that help anyone else come on Franco you got something so what another method for for kind of hanging on so in in android two points something that actually worked you could use both the the command was there there was actually an API to make your your process stick around am I out of town time well we can talk later thank you
Info
Channel: Touchlab
Views: 1,139
Rating: 4.818182 out of 5
Keywords: android, development, design, mobile, web
Id: JjhI8-SRnZA
Channel Id: undefined
Length: 39min 44sec (2384 seconds)
Published: Wed Nov 23 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.