Android Basics Using AIDE 2
Understanding the three important files in Android Development
0) Preparation
1) Open basic files using Sublime
2) AndroidManifest.xml
3) MainActivity.java
4) main.xml
This tutorial continues from http://tutorial.razi.net.my/2015/08/android-basics-using-aide-1.html
1.1) Look at the Project Folder and find AndroidManifest.xml, MainActivity.java and main.xml
This file defines the structure and metadata of your android application and its components - Read http://developer.android.com/guide/topics/manifest/manifest-intro.html
refer to line no.17, you can also write android:name="com.mycompany.myapp.MainActivity" . As a shorthand, if the first character of the string is a period, the string is appended to the application's package name. The statement tells the Android that the java class for the activity is MainActivity.java. |
Package Name Android follows normal java package conventions The reason for having it in reverse order is to do with the layout on the storage media. Import Statement The import statement imports types from a package by telling the compiler where to look for unqualified type names during compilation. android.app.* - Contains high-level classes encapsulating the overall Android application model eg activity android.os.* - Provides basic operating system services, message passing, and inter-process communication on the device. android.view.* - Provides classes that expose basic user interface classes that handle screen layout and interaction with the user. android.widget.* Java class MainActivity extends from Activity class. Read http://developer.android.com/reference/android/app/Activity.html In this example, MainActivity is using onCreate method of the Activity class. Read http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle) Refer line no.15, MainActivity is calling a layout resource file named main.xml. |
main.xml is a layout definition file. Read http://developer.android.com/guide/topics/resources/layout-resource.html |