Android Studio#6 - Empty Activity and it's Components | Part 1

 

Hello friends, welcome to the another tutorial of Programming Infinity. In this tutorial, we will know about the empty activity (an activity which is the basic of all activity), and also know about its various required parts, that works together for proper working of this activity and also for the app. We will first know about, how to create your first android app with empty activity. Afterwards, we will know about the empty activity and it's parts. So  friends, let's begin...

How to Create App

After Installing Android Studio and setting its environment variables, we are ready to get into Android Programming. If you had not done any of these, then read out the previous tutorials. So friends, let's know how to create our first hello world app with empty activity step by step :-


1. Open Android Studio. After loading its resources android studio will show a dialog like this for the first time. After creating certain projects for the app, it will be seen in the recent projects section, from where you can easily access it.
2. Click "Start a new Android Studio Project" for creating a new project. Below is the dialog shown, that will appear after clicking it. Here we had to fill the application name ( Remember to write your application name with a Capital Letter as it is not required, but all the apps currently in the market had its name started with capital letter ), company domain ( url website that you own, or something like 'yourname.com' or anything that you want if you had not any website owned or not yet designed for the purpose. you can also use your e-mail id as company domain. The android studio will automatically generate package name for the app. you can also edit the package name of the app ).
Browse and select for the project location for the app, where the android studio will create project and save resources for app to edit and develop the app and then click next.

3. Now a dialog will appear asking for selecting the form-factor for the app on which it run. The phone and tablet is by default selected and we had to go with it, as we had to now develop app for Android phones. There are also another android devices available on which you can develop your app. Now select the minimum SDK on which the app will run from the avialable options. The max SDK will automatically set from the max SDK installed on Android Studio. So regularly update platform and plugins in android studio for wider range of android API capabilities. The multi platform compatibility of android helps android app developer i.e. the developer had to only develop the app for one android app platform version and it will run on all the above android versions whose SDK is installed in the Android Studio. After all this, click next.


4. Its time to select the activity from which we start building our first app. In this tutorial , we will know about the empty activity. So select the empty activity and click next , a new dialog appears , click finish. Android Studio will now start creating project for app.


5. After sometimes, the project will finish building. Congratulations, we had now created our first app "hello world". Now we will learn about some important project parts, after then, we will start learning about the empty activity in details.

Project Resources


Resources means the required codes, layouts, colors, images, interface etc. that help the app to work properly by providing the required things when required. In the project, that we had created above, contains following described resources :-

  1. JAVA :- It contains the .java source code files for an app, which is executed by the Dalvik/ Android OS in runtime for providing specific designs, functions etc. to the app, which is described in the .java code.
  2. res :- It is a directory for all the resources for the app, which is accessed in the app through certain way. It includes every resources, properly arranged in sub-categories according to some common things ( text is stored along with text resources not with any another type of resource ).
  3. res/layout :- It is a resource sub-directory which stores XML designed UI, which we see, when we open the app. It contains only design/Structure of the components to prepare a perfect UI as developed by you. It doesn't contains any other things despite this. All the functions, programmatic customization of the layout is done through JAVA, that is seen only in runtime.
  4. res/Values :- It is a directory for XML files,  which stores some value as its content i.e. text resources known as strings, colors, dimensions etc.
  5. AndroidManifest.XML :- It is a XML file acts as a interface between the app and android os. It gives information to the OS about the components which is used, or about permissions. Without declaring any application component, which is used in the app, here will not be considered by the OS. So, it is necessary to define each components here for it to work properly. Instead of this, we can simply understand manifest as an xml file which describes the fundamental characteristics of the app and defines each of its components. We will know about it step-by-step in the upcoming tutorials.
  6. Build.gradle :- It is a auto generated file, which contains all the dependencies which is used in the app. It also contains some special information of the app as the CompileSDKVersion, buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, Versioncode and version name. We can add new dependencies here as required by us.
So friends, that's all for this tutorial. Hope u enjoyed this tutorial. If you have any question in this tutorial, then ask me in comment box.
Thanks -
Programming Infinity (Samridh Sharma).

Comments

Most Reads