- Getting Started / Hello World Basics
- Android Manifest File / Activities / Layouts
- Example Application: Building the Web View and Main Activity
Android Manifest File
The manifest file is the gateway to the application. It contains all the major settings that your application will use. You can think of it like a config file, because that is basically what this file is. You will notice that a skeleton manifest file was created for your project.
A good resource for learning about what this file does can be found on the Android Developer website.
Some important attributes to note for the manifest tag are:
- android:versionCode: This is the version or build/update number of your application. Each time you deploy the app, this number is to be incremented by 1. The Android Developer Console for Google Play uses this to identify the current version or "APK" file of your application. The APK file is generated each time you deploy the app and contains the "bytecode" for the application. It allows the application to run in a Java Virtual Machine environment, like the Android OS.
- android:versionName: The current version of your app (i.e., 1.0).
- android:installLocation: The location the app is to be installed (i.e., SD card or phone's storage space). A good setting for this value is "Auto".
The manifest tag is the root tag of the XML file. Inside this tag are all other tags for your app's settings. Some of the following are the most common and important:
- uses-permission: This tag defines any permissions your app needs access to on the user's phone. For example, to browse the Internet from your application, the Internet permission is required. There are all kinds of other permissions ranging from reading contacts to modifying audio settings. A good resource for learning what permissions are available can be found on the Android Developer website.
- application: This tag is the second major tag that includes most of the other nested tags for the manifest file. Some important attributes for this tag are:
- android:icon: This is the reference to your applications icon, which is a PNG graphic stored in your res/drawable folder. The res folder is a folder for Android resources such as your applications layout and graphics. The res folder contains numerous drawable folders, one for each screen resolution type. You can optimize your icon for each type of resolution (i.e., low, high, or medium).
- android:label: This contains the name of your app. You will notice that one of the subfolders of the res folder is called values. This folder contains all your string resources. When creating the project, the file strings.xml was created. This file holds all your application's strings. For example, the app_name string is the name of your application. The label attribute of the application tag in the manifest file refers to this string for your app name. The value for this attribute then becomes @string/app_name to signify that there is a string with the name 'app_name' in the strings.xml file that contains the application name.
- android:description: Your application's description. This attribute refers to the string name 'app_description' in the strings.xml file.
- android:theme: This is theme for your application. You can have a custom theme or use one of the default Android themes. For example, one default theme is called dialog. Using this theme, the screens in your application will use pop-up windows for each of the views. A good resource of themes is at the Android Developer website.
Activities are major components to an Android application. You can think of activities much like Windows Forms for Windows Programming or Views for Model View Controller (MVC) web applications. Each activity in your application represents a single user screen in your app. To create an Activity, you simply create a Java class and extend the class to use the Activity super-class. Because you are using the abstract Activity class that comes with the SDK, there are some methods you need to override. A default activity called MainActivity is generated when your project is created.
Layouts are XML files that represent the views for your activities. Each activity can contain multiple views, but only one view is active at one time. The Android SDK comes with a set of views to use in your application. These views allow you to align your input boxes, text, images, and more. The layout XML files are located in your res folder. A default view is created called main, and represents the main starting view for your application.