Share your knowledge

Friday 30 December 2016

Structure of Android Application

Below is the structure of an Android Project in Studio




 



































1. MyFirstApplication: This is the project name we gave in the initial stage of creation.

2. Icon: The icon pointing in the second arrow is used to filter the project with different modules as below.
  • Project
  • Packages
  • Scratches
  • Android
  • Project Files
  • Problems
  • Production
  • Tests
  • Android Instrumentation Tests
3. AndroidManifest.xml: This file is located under manifests folder, every application must have an AndroidManifest.xml file (With the same name) in it's root directory. This file provides essential information about your app to the Android System, which the system must have before it can run any of the
application code.
  • Contains all the application components(Activities, Services, Broadcast Receivers, Content Providers etc.) 
  • Contains information of the package
  • It declares which permissions the application must have.
4. Java Folder: All the java files will present inside this folder. By default it contains three packages with the same name you specified while creating the project.

5. MainActivity: This is the Activity you specified while creating project. You can find this Activity inside AndroidManifest.xml.


Below code can be found inside AndroidManifest.xml

 
 
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
 
 
 
We will discuss it briefly in the later sections.

6. (androidTest) and (test) packages: All the unit test related code will be present inside these packages.

7.res Folder: All the xml files will present inside this folder. By default few of the essential folders(drawable, layout, mipmap, values) and xml(activity_main, colors.xml, dimens.xml, strings.xml,styles.xml) files will be created.

8. drawable folder: Images you want to use in your application need to be placed here. we will discuss about it briefly later on.

9. layout folder: layouts will decide how our application user interface should look like, all the layouts will be created under this folder.

10. activity_main.xml: This is the file which decides how a screen(activity) should look like. An Activity with user interface should have a java file(in this case MainActivity.java) and an xml file(activity_main.xml).

11. mipmap folder: Here also we will keep images used in the application.
then, how are these mipmap images different from drawable images?
There are two cases you deal with when working with images in Android:
  1. If you want to load an image for your device density and if you are going to use it "as is", without changing its actual size, then you should work with drawables.
  2. If you want to load an image for your device density, but the image should to be scaled up or down. For instance this is needed when you want to show a bigger launcher icon, or you have an animation, which increases image's size. In such cases, to ensure best image quality, you should put your image into mipmap folder. What Android will do is, it will try to pick up the image from a higher density bucket instead of scaling it up. This will increase sharpness (quality) of the image.
    Note:
  • Launcher icons always go into mipmap folder.
  • Images, which are often scaled up (or extremely scaled down) and whose quality is critical for the app, go into mipmap folder as well.
  • All other images are usual drawables.
12. values folder: This folder contains other various XML files that contain a collection of resources, such as strings, colors, styles, dimensions etc

13.build.gradle: This is an auto generated file which contains compileSdkVersion, buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode and versionName, dependencies, etc. We will discuss about all of these in brief in later lessons.

 Few Java Basics Must know before starting to write something. 




No comments:

Post a Comment