Facebook

Start developing Android App in Android Studio

Hello Friends,

In the upcoming series of articles we will write about android application development using Android Studio.

This is the first article of this series and here we are explaining the steps of coding your first app , in full detail. We will start from very basics and slowly move to more complex and advance concepts.

So how to develop a simple HelloWorld app....steps below....

Start the Android Studio.
Go to 'file > New  > New Project ' menu.
Below Screen will appear.
 


Enter your Application's Name and your company Name. Application name will be the name you want to give to your android app, HelloWorld in this case.
Read my another blog post about 'Hello World' . Its an interesting read.
Company Name is used for package name inside your project structure.

Click next on this screen. You will see Target Android Device Screen.



This screen let you set the minimun API your application will support. In other words it let you set the oldest version of Android OS on which your app can be installed successfully. If you are developing your app for TV or other wearables then select the minimum SDK for all.
Click next on this screen and you will be prompted to select the activity type on next screen.


For our HelloWorld app we do not need any specific activity type. A simple blank activity can do the needful.
Click finish after selecting the  'Blank Activity'

Project will start building. Wait for few seconds as it may take some time initializing the project.


When project initialization is done, You will see the screen which will look like below image.


Left most pane is project structure given in tree hierarchy.
'app' folder consist of three sub-directories, 'manifests', 'java' and 'res'.
Manifests folder contains all the manifest files.
Java folder contain all the source packages.
'Res' folder contain all the resource file.


'Res' folder again have some sub-directories. We place images and custom layout xml files in this folder. XML layout files of all the activities are included in 'layout' folder. All the string literals are listed in values/string.xml file.
We will explain the use of all other directories at later stage.


In this app have already created a blank activity which by default contains a text view. Layout of the MainActivity is defined in activity_main.xml file inside layout folder. Default populated code in this file is given below.

   1:  <RelativeLayout
   2:      xmlns:android="http://schemas.android.com/apk/res/android"
   3:      xmlns:tools="http://schemas.android.com/tools"
   4:      android:layout_width="match_parent"
   5:      android:layout_height="match_parent"
   6:      android:paddingLeft="@dimen/activity_horizontal_margin"
   7:      android:paddingRight="@dimen/activity_horizontal_margin"
   8:      android:paddingTop="@dimen/activity_vertical_margin"
   9:      android:paddingBottom="@dimen/activity_vertical_margin"
  10:      tools:context=".MainActivity">
  11:   
  12:      <TextView android:text="@string/hello_world"
  13:          android:layout_width="wrap_content"
  14:          android:layout_height="wrap_content" />
  15:   
  16:  </RelativeLayout>

For now we will not add anything in this application. We will learn more in upcoming articles.

Lets now compile and install this app. You have two options to test the working application. Either run the emulator or use your android device. We will stick to the second approach as this give us the real time feedback about our app. Also emulator is too slow most of the times.
To run the app you need to connect your android device to your system.
If device is not being detected by your system then check of you have enabled 'USB Debugging' in developer options in your mobile's settings.




To run the application press shift+F10 or click the run button on the tool bar at top of screen. You can run application by clicking 'run' menu item.


A screen to select the device will appear. You can either launch an emulator or run the app on connected android device. I prefer later on. Click ok and your application will be installed on your device and will start.

You can see Hello World written on the screen. Right now this app doesn't do anything. This is simply displaying a text on screen. In the next article we will dive into more depth of code, how to create menu items, how to execute code when application starts and how to invoke another activity.





8 comments:

  1. Excellent post!!! Training on android technology helps professionals to establish a career in android mobile application development.
    Regards,
    Android Training in Chennai | Android Training|iOS Training in Chennai |iOS Training Institutes in Chennai

    ReplyDelete
  2. When you are going to start an app development process then you must fulfill the basic criteria for developing and app. If you are not familiar with the app development process then you must learn it first.

    ReplyDelete
  3. Android is the operating system which is spanning all across the world like forest fire. Android OS is based on the Linux kernel and is currently developed by Google.
    freedom app

    ReplyDelete
  4. Super site! I am Loving it!! Will return once more, Im taking your food likewise, Thanks. download

    ReplyDelete