Wednesday 16 January 2013

Android Development Tutorial (Based on Android 4.1) class-1

1. What is Android?


Android Operation System:


Android is an operating system based on Linux with a Java programming interface.

The Android Software Development Kit (Android SDK) provides all necessary tools to develop Android applications. This includes a compiler, debugger and a device emulator, as well as its own virtual machine to run Android programs.

Android is currently primarily developed by Google.

Android allows background processing, provides a rich user interface library, supports 2-D and 3-D graphics using the OpenGL libraries, access to the file system and provides an embedded SQLite database.

Android applications consist of different components and can re-use components of other applications. This leads to the concept of a task in Android; an application can re-use other Android components to archive a task. For example you can trigger from your application another application which has itself registered with the Android system to handle photos. In this other application you select a photo and return to your application to use the selected photo.

Google Play (Android Market)


Google offers the Google Play service in which programmers can offer their Android application to Android users. Google phones include the Google Play application which allows to install applications.

Google Play also offers an update service, e.g. if a programmer uploads a new version of his application to Google Play, this service will notify existing users that an update is available and allow to install it.

Google Play used to be called Android Market.

Security and permissions


During deployment on an Android device, the Android system will create a unique user and group ID for every Android application. Each application file is private to this generated user, e.g. other applications cannot access these files.

In addition each Android application will be started in its own process.

Therefore by means of the underlying Linux operating system, every Android application is isolated from other running applications.

If data should be shared, the application must do this explicitly, e.g. via a Service or a ContentProvider.

Android also contains a permission system. Android predefines permissions for certain tasks but every application can define additional permissions.

An Android application declare its required permissions in its AndroidManifest.xml configuration file. For example an application may declare that it requires access to the Internet.

Permissions have different levels. Some permissions are automatically granted by the Android system, some are automatically rejected.

In most cases the requested permissions will be presented to the user before installation of the application. The user needs to decide if these permissions are given to the application.

If the user denies a permission required by the application, this application cannot be installed. The check of the permission is only performed during installation, permissions cannot be denied or granted after the installation.

Not all users pay attention to the required permissions during installation. But some users do and they write negative reviews on Google Play.

2. Basic Android User Interface components


The following gives a short overview of the most important user interface components in Android.

Activity


An Activity represents the visual representation of an Android application. Activities use Views and Fragments to create the user interface and to interact with the user.

An Android application can have several Activities.

Fragments


Fragments are components which run in the context of an Activity. Fragment components encapsulate application code so that it is easier to reuse it and to support different sized devices.

Fragments are optional, you can use Views and ViewGroups directly in an Activity but in professional applications you always use them to allow the reuse of your user interface components on different sized devices.

Views and ViewGroups


Views are user interface widgets, e.g. buttons or text fields. The base class for all Views is the android.view.View class. Views have attributes which can be used to configure their appearance and behavior.

A ViewGroup is responsible for arranging other Views. ViewGroups is also called layout managers. The base class for these layout managers is the android.view.ViewGroup class which extends the View class.

ViewGroups can be nestled to create complex layouts. You should not nestle ViewGroups too deeply as this has a negative impact on the performance.

Activities, Fragments and Views


Activities are defined with different layouts. These layouts can be picked based on several different factoring including the size of the actual device.

The following picture shows an Activity called MainActivity. On a wide screen it shows two Fragments. On a smaller screen it shows one Fragment and allows that the user navigate to another Activity called SecondActivity which displays the second Fragment.

androiduicomponents10

No comments:

Post a Comment