Showing posts from October, 2011

Intents and Notifications

Intents are the messages that are used to activate following application components Activities Services Broadcast ReceiversIntent is an object, which has a data structure holding any one of the following data :Abstract description of an operation to be performed In the case of broadcasts, a description of something that has happened and is being announced.Invoking Components
Application components are invoked through intents in the following way : Activity : Intent object is passed to following functions to invoke the Activity. Context.startActivity (Intent intent) Activity.startActivityForResult (Intent intent, int requestCode)Service : Intent object is passed to following functions to invoke the Service.Context.startService (Intent)Context.bindService (Intent)Broadcast Receivers : Intent object is passed to following functions to invoke the Broadcast Receiver. Context.sendBroadcast ( Intent intent, String receiverPermission)Context.sendOrderedBroadcast ( Intent intent, String r…

Android: Menus and Dialogs

Table of contents:
1. Menus
Options menuContext menuSub menuCreating different Menus2. Dialogs
 Alert DialogProgressbar dialogDatePicker dialogTimePicker DialogToastCreating different dialogs Menus

Menus provide familiar interfaces to expose application functions without sacrificing screen space. Android offers an easy programming interface to provide standardized application menus.Android offers three fundamental types of application menus: Options MenuContext MenuSub-menu
Options Menu:

By default, every Activity supports an Options menu of actions or options. It is revealed by pressing the device MENU key.
Options Menu has two groups of menu items:Icon MenuCollection of maximum of six menu itemsSupports Icons and short-cutsExpanded MenuExposed by the 'More' menu itemDisplayed when the icon menu becomes over-loadedComprised of sixth options menu item and the rest.

Create Options Menu:

Following methods are provided by Activity class to create an Options menu :                 1  publ…

Android User Interface : Life cycles and Layouts

 Creating ActivityActivity LifecycleActivity LifetimeStarting ActivityProcess Lifecycle2. Layouts
 Creating LayoutTypes of layoutLayout parameters

An Activity presents a visual user interface for one focused endeavor the user can undertake.Each Activity represents a screen (similar to the concept of a Form in desktop development) that an application can present to its users.Most Activities are designed to occupy the entire display, but you can create Activities that are semi-transparent, floating (Activity working as a dialog).Creating an Activity:

 Create a new Activity by extending the Activity class.Override the onCreate() method to set the view for the activitySet the user interface to an Activity using the setContentView method in the onCreate method of the Activity.Use the findViewById(int) method to retrieve the reference of the widgets in UI.The basic skeleton code for a new activity is shown below :public class MyActivity extends Activity {
public void onCreate…