Android Basics Refresher
Join the DZone community and get the full member experience.
Join For FreeCovering the fundamentals of the hottest platform in mobile right now.
Reading through my Android notes today, I realised the quick-read format might be useful to others. Although fellow zoneleader James has been featuring some excellent articles on Android, I'd thought give my take in a simpler format - just in case it triggers your memory.
Android BasicsEvery app;
- runs in its own Linux process
- shutdown when more resources needed
- each process has its own VM
- assigned its own user ID so its data is visible only to that user (and app)
- can call upon components developed elsewhere to allow for reusability
An activity is a UI representing a task the user wants to perform, such as entering a phone number into a text-box, or a list of menu items the user must choose from. Applications are made up of many activities. A Java class must extend the Activity class.
Views, or 'widgets', are what make up the components in an activity. As subclasses of View, these represent standard items in a UI such as a button, textbox or Image.
Services, Broadcast Receivers and Content Providers ServicesRun in the background. Extend the "Service" base class. The platform will start them by passing Intent to Context.startInstance(). "onStart()" will be called by Android on the instance of a new Service and an Intent passed to it. To get a hold of an established Service (i.e. one that's already running), you can call Context.bindService(); in such a scenario the Service is given an Intent instance and its onBind() method is called.
Broadcast ReceiversReceive and react to broadcast announcements. Examples would be battery is low, or the language has been changed. Extend BroadcastReceiver base class. They do not have a an interface and typically display an icon in the notification area.
Content ProviderExposes one application's data to another. An extension of ContentProvider, these act on calls from ContentResolver (which other apps invoke) to access data controlled by this provider.
IntentsActivities are started by passing Intent instances to Context.startActivity() or Activity.startActivityForResult().
I hope that helps someone out there!
Opinions expressed by DZone contributors are their own.
Comments