Android podcast notes
Notes from the recent Android podcast…
- Dalvik VM can mmap dex files.
- Zygote loads VM before forking, so copy-on-write effective and all apps share lots of pages.
- ‘am’ command doesn’t work that way; can get idea of benefit; takes 2 seconds to launch because it has to load all classes.
- Different user for each application. Your data is UID’d to you on the filesystem too.C
- Content providers use URL scheme. Every bit of data on device has a unique name.
- Intents are just a generic way of naming something to do. e.g. I’d like a content. Then system finds something like the contacts app. Similar for playing an MP3, any media player app can fulfil intent.
- Intents are broadcast; anyone can reply.
- Embedding in UIs not supported.
- XML gets compiled down. Generic binary format for XML, the compiler can reduce any XML.
- Reference HW has 64MB RAM, 128MB flash. No virtual memory practically. Yet Linux is aimed around VM. For example when creating a thread, Linux allocates a heap of virtual address space for the program (but only allocates physical pages later). If RAM unavailable, would have to kill app, can’t fail the malloc.
- So component model allows kernel to identify which applications aren’t needed, and kill them if there are insufficient pages.
- Threads: tried hard to avoid needing an app to have multiple threads. Everything designed to happen in main thread. But of course you need to remain responsive in main thread.
- A service is not a main thread either. When you start a service it runs on the main thread still.
- UI framework not thread-safe, for efficiency. Must access UI object from main thread. Use Handler object to do that.
- Handler also allows timer services; can request an event in the future.
- Current UI is somewhat of a placeholder
