Getting started with android

Before you start with coding lets download & install Android Studio.Over here you can find all the details regarding Installation, System Requirement, Command line tools etc. Now after the successful installation of android studio lets get started with simple Android application.
   
Create An Android Application

After successful installation of android click on android studio.Sometime it takes some time to load depending on your system so, be patience.Once the android studio started it show screen like below.


Now click on "Start a new Android Studio Project" and then you move to "Configure your new project" screen like below.


Here it will ask you to enter 
  • Application Name
  • Package name (It will automatically taken from company domain)
  • Project location (Your Project Directory where you want to save)
Now we let us enter the application name as "FirstAndroidApp" then company domain "droid.com" so it will automatically append our project name so the final package name will be "droid.com.firstandroidapp" now hit the next button and it will show the below screen and ask to choose minimum sdk.Let's choose Android 5.0 Lollipop. and then Press next.

Note: If you don't have the 5.0 Lollipop choose the version whatever you have.



Now the below screen is add an activity to mobile layout for your application.For our example we choose empty layout and click on next.




Now on the customize activity screen it will show by default Activity name as MainActivity and Layout name as activity_main.If you want to change the
  • Activity Name
  • Layout Name 
  • Backward compatibility (AppCompat)
you can change it with your own names.Right now we leave it as it is no change for it.For our example we don't need the Backward compatibility so uncheck it.


Now as soon as you hit the finish your project start building it takes some moment to build the project.After successfully build the project you can see the below screen.


Now you can see many directories and files in android project before run the application we just go through it what are the use of them.For brief idea you can refer this project overview.

Main Activity :  

Main activity file is java file where it's extension is .java. The code shows here is default generated code by application.On the top you can see the Package com.droid.firstandroidapp is our package name.OnCreate() method is a part of Android life cycle when application is launch it load the layout.R.layout.activity_main is the xml layout file in which you can create your own design layout.


Layout R.layout.activity_main :

The R.layout.activity_main is the layout file here you can change the layout of application.You can see the <TextView tag in that you see the android:text when you
run the application this Hello World is show in the layout.

AndroidManifest.xml :

In androidmanifest.xml all your activity, service, receiver, permissions,
intent-filters, providers and many more elements are define here.You can learn
more from here about manifest file.

Build.gradle :

This is the gradle file where you can set all your dependencies, version name,
version code, targetSdkVersion, minSdkVersion, compileSdkVersion and
many more.You can learn more about build.gradle from here.

Now let us run the application.Oh! wait do you setup the environment to run the android application? And the answer is no.Let us setup AVD environment to run the project.


Now Go to Run -] Run 'app'. Once you click on Run 'app' it will start building app and then it will automatically start the AVD and you can see the HelloWorld in AVD.



Comments

Popular posts from this blog

Upload Image using okHttp

How to blur background images?

How to remove a particular activity from android stack?