UI Features and Design Guidelines for Android 4.4 KitKat | Android Video Tutorial

Join Nick Butcher, Adam Koch and Roman Nurik as they discuss various elements of Android Design. This week, we'll cover the new UI features and design guidelines for Android 4.4 KitKat.

Slides are available here: https://plus.google.com/+RomanNurik/p...

Storage Access Framework in Android 4.4 KitKat | Android 4.4 KitKat Video Tutorial

Get up to speed on the new storage access framework in Android 4.4 KitKat. This video gets you up and running with your own DocumentProvider by stepping you through the making of a simple cloud storage app.

Send and Receive SMS and MMS Messages Using Android 4.4 SMS API | Android Video Tutorial

Android 4.4 KitKat introduces the new SMS APIs as well as the new concept of a default SMS app. This video discusses these new APIs and how your app should use them to send and receive SMS and MMS messages.

How To Animate Card Flips And Rotations | Android Programming | Video Tutorial


This video tutorial shows how the basic graphics and animation APIs can be used to rotate and flip views from different perspectives, as well as how to apply darkening shadow effects onto a View.

What's New in Android Developer Tools 2013? | Android | An In-depth Video Tour

An in-depth tour of the Android development tools, with a closer look at everything new - along with tips and tricks for getting the most out of them presented during Google I/O 2013

Activity Overview | Android

Activity is similar to winform in .Net. Every application will have one main Activity which will be shown to the user when launching the application for the first time. An activity can start another activity.

Every time a new activity is started, the previous activity will be stopped and preserved in the stack called back stack.

Building an Intent | Android

An Intent object binds two activities (components) during runtime. An Intent is an app’s intention to do an action. In other words, an intent is an abstract description of an operation to be performed. Intent can be used with startActivity to launch another Activity.

Let's create an Intent to start an activity called ShowMessageActivity.

Intent intent = new Intent(this, ShowMessageActivity.class);

The constructor of the Intent is called with two parameters of type Context and Class. Here, this is the Activity class passed as the first parameter. Activity class is a subclass of Context. Second parameter ShowMessageActivity.class, is the Class of the activity that should be started to which the system should deliver the Intent. Here, it is ShowMessageActivity.

Button Click Event | Android Programming

android:onClick attribute is used to add click event to the <Button> element as below.

    android:onClick="submitMessage" />

In the above code snippet, we have added the name of the method submitMessage to the android:onClick attribute. This method will be called when the user clicks the button.

Now, let's add the below code snippet to the respective class located in the project's src/ directory for the method submitMessage

public void submitMessage(View view) {
    // submit the changes in response to button click
Additional Steps
  • Import the View class: import android.view.View;
  • Method should be public
  • Method return type should be void
  • Method should have only one parameter of type View {here, it View be the view object that was clicked}

Adding a Button | Android Programming

Button is a view object that can be added to the layout. Below is a sample code that represent a button in a layout.


The height and width of the button layout are set to wrap_content to fit the button's text. The button's text will be retrieved from the string resource by button_send.

Adding String Resources | Android Programming

String resources are used to manage all UI text in a single location. Localization can be achieved by defining various definition for different languages.

Android includes a string file at res/values/strings.xml, by default. You will find "hello_world" string in the resource file when opened.

<string name="hello_world">Hello world!</string>

Let's delete the above string and define as below to understand the Android string resources better

<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">My Hello World Android Application</string>
    <string name="edit_message">Enter your first message in Android Application</string>
    <string name="button_submit">Submit</string>

Adding a Text Field | Android Programming

<EditText> element is a View object used to create a user-editable text field. Let's look at a sample XML layout code snippet to demonstrate this

<EditText android:id="@+id/edit_message"

In the above sample code snippet, you can see few XML attributes used to setup the properties of <EditText>.

android:id is used to provide a unique identifier for the view. The at sign (@) is used in android:id, followed by the resource type (id), a slash and resource name (edit_message) to refer any resource object from XML.

android:layout_width and android:layout_height are used to specify the size of the element. Here, wrap_content is provided for these attributes to specify that the size of this view object (here, EditText) should fit the contents of the view.

android:hint is used to default a string to display when the text field is empty. For example, You could have noticed a water mark text in an empty text boxes in few websites. Similar effect can be achieved using this XML attribute. In the given sample code, the default string will be read from a resource file.

Creating A Linear Layout | Android Programming

LinearLayout is a type of layout from a view group. It helps to arrange the child views in either a vertical or horizontal orientation. Each child view will appear on screen in the same order as in XML.

When you create a project with the BlankActivity template, it includes the activity_main.xml file with a RelativeLayout root view and a TextView child view.

Let's delete the <TextView> element and change the <RelativeLayout> element to <LinearLayout>. Then add the attribute, android:orientation and set it to "horizontal".

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

As you can see in the above example, the root view LinearLayout should fill the entire screen area. This is achieved with the help of the attribute value match_parent. It states that the view should expand its width and height to match the width and height of the parent view

The attributes, android:layout_width and android:layout_height, are required for all views to specify their sizes.

Graphical User Interface | Android Programming

The graphical user interface for an Android application is constructed by a hierarchy of View and ViewGroup objects.

View objects

View objects are UI widgets such as buttons or text fields.


ViewGroup objects defines the layout of the child view like in a grid or a vertical list. Basically, ViewGroup are invisible view containers.


Android provides an XML vocabulary to define your UI in XML using a hierarchy of UI elements. We can define subclasses of View and ViewGroup in the XML.

Check Mobile Network Availability By Code | Android Programming

Below code snippet checks for the availability of network signal on Android device

public static boolean isNetworkAvailable(Context ctx) {
 ConnectivityManager connMgr = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
 if(connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected() ||
   return true;
 return false;

This function will return true if either WIFI or MOBILE network available, otherwise returns false.


ConnectivityManager is a class used to monitor network connections (Wi-Fi, GPRS, UMTS, etc.). It exposes functionalities that allows applications to query the state of the available networks.

How to instantiate ConnectivityManager class?

ConnectivityManager class can be instantiated by calling Context.getSystemService(Context.CONNECTIVITY_SERVICE).