Android development tutorial


Following is a number of lessons on Android programming. Since each section includes exercises and use solutions, this may also be seen like a self-paced Android training program. Click a piece below to grow its content. These lessons think that you know Java they certainly move too quickly for individuals without a minimum of moderate prior Java experience. If you do not know the Java language

1. What is Android?
1.1. Android Operation System
Android is definitely an operating-system according to Linux having a Java programming interface.The Android Software Development Package (Android SDK) provides all necessary tools to build up Android programs. Including a compiler, debugger along with a device emulator, along with its own virtual machine to operate Android programs.

Android is presently mainly produced by Google.
Android enables background processing, supplies a wealthy interface library, supports 2-D and three-D graphics while using OpenGL libraries, accessibility file system and offers an embedded SQLite database.

Android programs contain different components and may re-use aspects of other programs. This can lead to the idea of an activity in Android a credit card applicatoin can re-use other Android components to archive an activity. For instance you are able to trigger out of your application another another application that has itself registered using the Android system to deal with photos. Within this other application you choose a photograph and go back to the application to make use of the chosen photo.

1.2. Google Play (Android Market)
Google provides the Google Play service by which developers can provide their Android application to Android customers. Google phones range from the Google Play application which enables to set up programs.

Google Play also provides an update service, e.g. if your programmer uploads a brand new form of his application to Google Play, this particular service will inform existing customers that the update can be obtained and permit to set up it.

Google Play was once known as Android Market.

1.3. Security and permissions
Throughout deployment with an Android device, the Android system can create a distinctive user and group ID for each Android application. Each application file is private for this produced user, e.g. other programs cannot access these files.

Additionally each Android application is going to be began in the own process.
Therefore by way of the actual Linux operating-system, every Android application is isolated using their company running programs.If data ought to be shared, the applying should do this clearly, e.g. using a Service or perhaps a ContentProvider.Android also consists of a permission system. Android predefines permissions for several tasks but every application can define additional permissions.An Android application declare its needed permissions in the AndroidManifest.xml configuration file. For instance a credit card applicatoin may declare required internet access.Authorizations have different levels. Some permissions are instantly granted through the Android system, some are instantly declined.

Generally the asked for permissions will be provided towards the user before installing of the applying. The consumer must determine if these permissions receive towards the application.

When the user declines a permission needed through the application, this application can’t be installed. The check from the permission is just carried out throughout installation, permissions can’t be refused or granted following the installation.

Not every customers give consideration towards the needed permissions throughout installation. However, many customers do plus they write negative reviews on the internet Play.

2. Fundamental Android Interface components
The next provides a short overview of the most basic interface components in Android.

2.1. Activity
A Task signifies the visual representation of the Android application. Activities use Sights and Fragments to produce the interface and also to connect to the consumer.

An Android application might have several Activities.

2.2. Fragments
Fragments are components which run poor a task. Fragment components encapsulate application code to ensure that it’s simpler to reuse it and also to support different sized products.

Fragments are optional, you should use Sights and ViewGroups directly within an Activity however in professional programs you usually rely on them to permit the reuse of the interface components on different sized products.

2.3. Sights and ViewGroups
Sights are interface icons, e.g. buttons or text fields. The bottom class for those Sights may be the android.view.View class. Sights have characteristics which may be used to configure the look of them and behavior.

A ViewGroup accounts for organizing other Sights. ViewGroups can also be known as layout managers. The bottom class of these layout managers may be the android.view.ViewGroup class which stretches the vista class.

ViewGroups could be situated to produce complex designs. You shouldn’t nestle ViewGroups too deeply because this has an adverse effect on the performance.

2.4. Activities, Fragments and Sights
Activities are defined with various designs. These designs could be selected according to a number of different invoice discounting including how big the particular device.

The next picture shows a task known as MainActivity. On the lcd screen it shows two Fragments. On the more compact screen it shows one Fragment and enables the user navigate to a different Activity known as SecondActivity which shows the 2nd Fragment.

3. Other Android components
Android has lots of more components which may be utilized in your Android application.

3.1. Intents
Intents are asynchronous messages which permit the applying to request functionality using their company aspects of the Android system, e.g. from Services or Activities. A credit card applicatoin can call an element directly (explicit Intent) or request the Android system to judge registered components in line with the Intent data (implicit Intents ). For instance the applying could implement discussing of information with an Intent and all sorts of components which permit discussing of information could be readily available for the consumer to choose. Programs register themselves for an Intent with an IntentFilter.

Intents let it mix loosely combined components to do certain tasks.

3.2. Services
Services perform background tasks without supplying a interface. They are able to inform the consumer through the notification framework in Android.

3.3. ContentProvider
A ContentProvider supplies a structured interface to application data. Using a ContentProvider the application can share information along with other programs. Android consists of an SQLite database that is commonly used along with a ContentProvider. The SQLite database would keep data, which may be utilized through the ContentProvider.

3.4. BroadcastReceiver
BroadcastReceiver could be registered to get system messages and Intents. A BroadcastReceiver can get informed through the Android system, when the specified situation happens. For instance a BroadcastReceiver might get known as when the Android system completed the boot process or maybe a telephone call is received.

3.5. (HomeScreen) Icons
Icons are interactive components that are mainly utilized on the Android homescreen. They sometimes display some type of data and permit the consumer to do actions via them. For instance a Widget could display a brief review of new emails and when the consumer chooses an e-mail, it might start the e-mail application using the selected email.

3.6. More Components
Android provide a lot more components however the list above describes the most crucial ones. Other Android components are Live Folders and Live Wallpapers . Live Folders display data around the homescreen without starting the related application while Live Wallpapers let it create animated skills.

4. Android Development Tools
4.1. Android SDK
The Android Software Development Package (SDK) consists of the required tools to produce, compile and package Android application. Many of these tools are command line based.

The Android SDK offers an Android device emulator, to ensure that Android programs could be examined with no real Android phone. You may create Android virtual products (AVD) through the Android SDK, which run within this emulator.

The Android SDK consists of the Android debug bridge (adb) tool which enables for connecting for an virtual or real Android device.

4.2. Android Development Tools
Google offers the Android Development Tools (ADT) to build up Android programs with Eclipse. ADT is some components (plug-inches) which extend the Eclipse IDE with Android development abilities.

ADT consists of all needed benefits to produce, compile, debug and deploy Android programs in the Eclipse IDE. ADT also enables to produce and begin AVDs.

The Android Development Tools (ADT) provides specialized editors for assets files, e.g. layout files. These editors let it switch between your XML representation from the file along with a more potent interface via tabs at the base from the editor.

4.3. Dalvik Virtual Machine
The Android system utilizes a special virtual machine, i.e. the Dalvik Virtual Machine to operate Java based programs. Dalvik uses an own bytecode format which differs from Java bytecode.

So that you cannot directly run Java class files on Android, they have to get converted within the Dalvik bytecode format.

4.4. How you can develop Android Programs
Android programs are mainly designed in the Java programming language. The Java source files are transformed into Java class files through the Java compiler.

The Android SDK consists of something known as dx which converts Java class files right into a .dex (Dalvik Executable) file. All class files of 1 application are put in a single compressed .dex file. Throughout this conversion process redundant information within the class files are enhanced within the .dex file. For instance when the same String can be found in different class files, the .dex file consists of just once reference of the String.

These dex files are thus much more compact in dimensions compared to corresponding class files.

The .dex file and also the assets of the Android project, e.g. the pictures and XML files, are packed into an .apk (Android Package) file. This program aapt (Android Resource Packaging Tool) works this packaging.

The resulting .apk file consists of all necessary data to operate the Android application and could be used for an Android device through the adb tool.

The Android Development Tools (ADT) works these steps transparently towards the user.

If you are using the ADT pedaling you press a control button the entire Android application (.apk file) is going to be produced and used.

4.5. Resource editors
The ADT enables the developer to define certain items, e.g. Strings and layout files, in 2 ways: using a wealthy editor, and directly via XML. This is accomplished via multi-page editors in Eclipse. During these editors you are able to switch between both representations by hitting the tab around the lower area of the screen.For instance should you open the res/layout/primary.xml file within the Package Explorer Look at Eclipse, you are able to switch between your two representations as portrayed within the following screenshot.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>