Saturday, July 11, 2015

Android App Development - App SW Components

Android Apps require a Manifest, Layout, Resources, and Java


Most mobile developer know that Android phones are powered by Java and iOS phones are powered by Swift (was Objective-C).  The Java language was invented by Sun. It was an OOP language like C++, but with some differences such as automatic memory management in Java. The salient feature of Java, though, was Write Once Run Everywhere. This was possible because Java compiler produced machine independent Java bytecode that can run on any Java Virtual Machine (JVM). So your HelloWorld Java bytecode can be compiled once and run on your laptop, mobile device, and even your DVR if it has the JVM built in.

So Java seems ubiquitous - but how does it survive on an Android mobile device? Very well. Because Java is OOP, and  the Android framework treats everything as a class (the main screen is an Activity class, the button is a Button class, etc).

1. Manifest (XML)

The manifest lists the major top level components of an Android app - such as Activities (an Android window), Services (background programs that run silently), etc. The manifest identifies which Activity is the main one that the user sees when the app is first invoked. The manifest is written in XML and is created manually by the user via the Android Studio.

2. Layout (XML)
 
The window inside of an Android application can be laid out via several built in Android layouts (List, Grid, Relative, etc). This is where the designer can point to where buttons should reside, where the image should appear, etc. The process to create an layout is 1. pick a built in Android layout 2. customize the layout using either XML or drag-n-drop GUI in Android Studio. Once the layout is specified, it can be altered programmatically as the app is running.

3. Resources

Android apps usually have icons, built in pictures and sound that part of the app. These are all located in a central place called resources. The labels on your buttons, such as "Submit", are found in the central resource. One of the benefits of this is that if the app needs to be translated into another language, all of the English text is found in one place and the translation can be done in the resource - as opposed to searching through every file to replace. Some discipline is needed to adopt resource while developing an app.


4. Activity Java

The app's main control logic and the heart of the program is located here. "Activity" is another name for the main window in Android. Because it is written in Java, the developer have access to all Android objects from here can can read, calculate, output to Java Views such as buttons, text, etc.

Conclusion

Android apps are written in standard Java. But knowing the Java language is not enough. You will need to also understand the other components : the Manifest, the Resource, and Layout.

No comments :

Post a Comment