Android programming first tutorial

 
Android is an "open source" operating system.It was created to allow developers to take full advantage of all that can offer a mobile device. 
Android is dedicated to mobile devices, smartphones and tablets, Smart TV etc.
In the year 2005, Google acquired Android Inc., a small startup in Palo Alto.
Android is essentially based on the Linux kernel, but its interface was developed in Java. 
Android is supported by a consortium made up of very diverse businesses, operators (T-Mobile, Bouygues Telecom, etc.), manufacturers (Samsung, LG, HTC, etc.) and many other company (eg smelters, with Intel, Qualcomm or Nvidia). This consortium is called the Open Handset Alliance (OHA).
I. Development Environment 
You can download the entire developement environment from this link : http://developer.android.com/sdk/index.html
To develop an Android application you will need: 
• The Eclipse code editor .
• To develop Android programs with Eclipse, it must integrate the ADT  plug-in (Android Development tools).
• The android SDK (Software development kit) .You can download the SDK from this website http://developer.android.com/sdk/index.html (after a recent update this link provides Bundle which includes the entire development environment  Eclipse + ADT plugin+ Android SDK) 
   
After downloading these tools, it is better to create a specific folder (called Android in C: for example) in which it is decompressing the SDK and Eclipse (or the ADT Bundel). You should also create a sub-folder in this folder there which will be the Eclipse workspace in which saves your projects. 
Note: If Eclipse will display an error after it starts, so you need to install the JRE (Java Runtime Environment).
II. Create an emulator 
Open the Android Virtual Device manager

Emulators are used to run the codes that we will develop in the code editor without having to connect a real phone to test the code. 
To create an emulator you need just to click on the little icon at the top "open the Android Virtual Device Manager" Then you click on "new" in Virtual Device manager. 
Then you have to give  a name for this emulator and choose the android version that will be running on the emulator and than click create AVD.
Emulator (virtual device)


III.First Android Project
1- Start Eclipse 
2- Click "File" then "New" 
3- Choose android application project 

4- Give a name to your project and your application and package that will contain your activities and than click next

Create a project

5- Choose "Create Activity" then choose "empty Activity" and then give a name to this Activity and click finish.
Choose Create Activity


Choose an icon image if you selected "create custom launcher icon"
                                     

Choose Empty Activity
Give a name to the Activity (Java class) and a name for the graphical layout  than click finish

To run your project (you must have an existing emulator to run your projects) you must click with the right button of the mouse on the project folder (Hello )   and choose run as android application.  
skeleton of an android project 
Your emulator will take a little time to run your application, you can know if your application starts running  or not if you follow what is written in the "console" which is located at the bottom in eclipse.
Ensure that "Android" is the display selected console.
Display Selected Console button (in the blue circle)
If the console displayed this text that's mean that your application is installed and starts running on the emulator ,you can than see your application running on the emulator :
 Installing Hello.apk...
 Success!
 Starting activity com.example.hello.MainActivity on device emulator-5554
ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hello/.MainActivity }

The application "Hello" running on the emulator
We have  to talk a bit about the architecture of an android project as displayed in the "skeleton of an android project " picture.
● AndroidManifest.xml is an XML file that describes the application to build and its components: activities, services, etc. 
● bin / contains the compiled application. 
● gen / contains the source code produced by the compiler tools for Android. 
● libs / contains the external JAR files required for the application. 
● src / contains the Java source code of the application. 
● res / contains resources - icons, descriptions of the elements of the GUI 
(layouts), etc. - Packaged with the compiled Java code. 
● assets / contains other static files provided with the application for deployment on the terminal.

                                                       
                                   

                                   

                                   

Commentaires

Posts les plus consultés de ce blog

Premier tutoriel avec Arduino et Proteus ISIS

Login et password ,formulaire d'authentification sous android avec mysql et json

Connexion d'une application Android et une base de données externe Mysql avec web services php Json (opérations CRUD)