In the series of articles introduced previously, we have covered where to download the key SDK and tools and how to install them, how to start developing and debugging your apps, how to package them before publication, and what popular app stores to distribute to your potential users. Of course, the ultimate goal is to develop apps with popular features that many people love and meanwhile boost your own sales and business opportunities.
Working on Android puts you in an excellent position of addressing a bigger audience than the iOS community. Since Android hardware devices come in different screen sizes, processor types, custom APIs, etc., it also poses more challenges to maintain similar execution performances and user experiences in such variations. Google’s official Android site offers design tips, so you are highly recommended to check them out at http://developer.android.com/design/.
App development tips from experienced developers vary from author to author, so I also compile a list of my own to share with fellow developers and hope they provide a different perspective for you.
[TIP]: Research for Popular Apps
Almost all the major app stores offer statistical numbers or rankings for customers to go to the top popular apps directly. For example, Google Play market as in Figure 1 lists the apps under the “Top Charts” categories in “Top Paid”, “Top Free”, “Top Grossing”, etc. They also have in the general section: “Editor’s Choice”, “Most Popular Apps”, “Recommended for You”, “Our Favorite This Week”, etc. You should wonder why some apps can stand out and make these lists out of a gigantic pool of apps. First off, before you actually start writing your own apps, you definitely want to research the market if there are already exisiting apps providing the planned features. If there are, then take notes about what they provide and ask yourself if you are confident in doing better. If there are not, you should evaluate and think about whether your apps bear potentially similar characteristics as those in the top categories. Visit the app stores periodically and keep your notes about top apps for future development. You can compile a list of rules of how you evaluate those apps, e.g. “Ease of Use”, “Fun Factor”, etc.
Figure 1: Top Apps
[TIP]: Model After Existing Sample Codes
If you recall when we installed the Android SDK, there are several great sample projects inside sdk/extras/android/support/samples/ It has a sample app API Demos showcasing almost all the user interface examples and major functionalities, which you can use as templates to build and modify for your apps. You can also find many more complicated Android projects at Google Code site. There are some advantages in doing so. Not only is it convenient to have the working template, but you also have something right to start with, especially for beginners. Experienced developers will also reveal some great tricks in their projects, which are rare to find in general tutorials or books. Do remember to pay attention to the code license and give proper credit to original authors when needed.
[TIP]: Avoid Undocumented APIs
After you have seen more apps and become more experienced, you will perhaps start wondering about how some great features are done in Google’s own apps and check into their platform codes. For example, I tried to micmic the image cropping functionality by studying the system Camera app after a picture is taken.
Intent intent = new Intent("com.android.camera.action.CROP"); intent.setClassName("com.android.camera", "com.android.camera.CropImage");
It worked at first but after a few Android SDK updates, it stopped working. Another common way of hacking into using internal Android APIs is called Reflection, which basically works like this – even if you don’t know what object you are using, you can find out information about it and then use that information to call its methods. For example, the following refection method is used to enable the Bluetooth option.
Object obj = getSystemService("bluetooth"); Class c = manager.getClass(); Method m = c.getMethod("enable"); m.setAccessible(true); m.invoke(obj);
All the above are undocumented and there is no guarantee they will still work after future updates. You should try to avoid developing apps with these approaches.
[TIP]: Consider Layout for Device Orientation and Various Screen Sizes
Since devices have embedded orientation sensors and they are usually defaulted to automatic mode, we need to account for that to provide a better user experience. In the screeshots Figure 2.1 and Figure 2.2, you can see the content is selected to display differently for landscape and portrait modes due to the device screen’s available space. To achieve this, all you need is to set up the layout folders with different qualifiers in land and port so that the system will apply the appropriate layout in auto orientation mode.
YourProject/ src/ YourActivity.java res/ drawable/ icon.png layout-land/ main.xml layout-port/ main.xml values/ strings.xml
Android devices come in different screen sizes, ranging from small phones to big TV sets, so it is crucial to make your app compatible with various screen sizes so it is available to most users and provides optimal user experience for each screen configuration. Some key pointers offered by the official documents are: ensuring your layout can be adequately resized to fit the screen, providing an appropriate UI layout according to screen configuration, ensuring the correct layout is applied to the correct screen, and providing bitmaps that scale correctly. For more detail, please check out http://developer.android.com/training/multiscreen/index.html
Figure 2.1: Portrait Mode
Figure 2.2: Landscape Mode
[TIP]: Support Different Languages with Localization
Since Android devices are available in many regions, you should design your apps to the locales where your application will be used. Most or all of the items of the user interface that can be localized should be stored onto separate resource files. Specifying the configuration language and region qualifier will automatically switch to the device’s default locale.
Assume English is the default language for your app, but you are expecting lots of Japanese devices will be installing it. Under values-ja/ parallel to the default values/ folder, you can target those devices by providing alternative text strings completely in Japanese. In this example, ja is what we call the language and region qualifier. For more detail about supporting multiple languages, please see http://developer.android.com/training/basics/supporting-devices/languages.html
YourProject/ src/ YourActivity.java res/ drawable/ icon.png layout/ main.xml values/ strings.xml values-ja/ strings.xml
[TIP]: Always Test on Hardware Devices
There is really no better way of testing your apps than on the actual hardware devices. No matter how closely your emulator is configured to match up with the hardware specifications, it could still be different from the reality. Therefore, whenever possible, at least have your apps tested on the most popular hardware devices and get a sense of how your apps look and perform on them. In the tutorial, “Building Your First Android App”, we have a section “Connecting with Hardware Devices” showing you how you can set up the device connection and directly debug it if needed. In the Android world, testing is especially challenging since there are so many combinations of platform API versions and hardware configurations. Over the years, it seems to get easier since more and more recent devices are adopting the latest APIs and providing system updates more often.
[TIP]: Empower Your Apps with Cool Android Features
Android APIs offer many great features you should always consider adding to your apps. You can include Speech Recognition (See http://developer.android.com/reference/android/speech/SpeechRecognizer.html), Gesture (See http://developer.android.com/reference/android/gesture/Gesture.html), etc. as your app’s input options. Text-To-Speech (TTS) (See http://developer.android.com/reference/android/speech/tts/TextToSpeech.html) can be used to provide disability help for visually impaired users. Embedding Google’s state-of-the-art search engine (See http://developer.android.com/guide/topics/search/index.html) can make your app reach out to provide better content. Displaying results in Google Maps (See https://developers.google.com/maps/documentation/android/) boosts the location awareness in the apps. Use media APIs to make your apps work directly with the audio and video files.
[TIP]: Consider Native Coding for Performance
Some apps do require high-performance CPU-intensive operations or need to integrate with native-code languages such as C and C++. You should consider looking into the separate download for NDK from: http://developer.android.com/tools/sdk/ndk/index.html
NDK is a set of tools for generating native-code libraries from C and C++ sources and a way to embed the corresponding native libraries into your app package file to be deployed on Android devices. However, you also need to keep the pros and cons of using NDK in mind. It always increases your app complexity, but does not always result in a significant performance gain.
[TIP]: Keep Apps Responsive and Inform About Necessary Wait
We all get annoyed when the device hangs or freezes for a long period of time. And you have probably seen the “Application Not Responding” (ANR) dialog on some Android devices and apps simply come to a stop without responding to any input. This happens when an app blocks on some I/O operation on the UI thread so the system cannot process incoming user input events usually within 5 seconds approximately.
If you have some complicated operations that can potentially take a while, you should consider creating a separate worker thread running in the background. Android provides an easy-to-extend AsyncTask class for this purpose. Of course, you can still implement your own through Thread and Handler for a more detailed control. Whenever a long wait is inevitable, you should always present a message dialog or progress bar to keep your users notified. You can also use performance tools (e.g. Traceview) to evaluate your app’s responsiveness.
[TIP]: Value User Suggestions
Before your apps are made available to the general public through app stores, all of the key features, functionalities, user interfaces, etc. are mainly decided by you or a small circle of family and friends surrounding you. Whatever features that have been deemed as cool or useful might not generate any interest among any of your customers. Most app stores provide rating or review systems for your users to make comments and suggestions to your apps, e.g. Figure 3 from Google’s Android Developer Console. You get the opportunity to read through user comments and even respond to the individuals if you will. Over time, these suggestions generally will make your apps grow into the products with the features people really want. Your users will also grow into becoming your longtime customers since they know you value their feedback.
Figure 3: Ratings and Reviews
This tutorial outlines the overall design tips used in developing Android apps. Due to Android platform’s versatile characteristics, it has been used on many hardware devices in phones, tablets, smart watches, home appliances, and a long list of other amazing mobile devices. With careful design consideration in these factors, your apps would definitely have the advantage of becoming more popular in the ever growing market base. Always keep a close watch on the market trend as well. That way, you can keep yourself up with the necessary skills to dive into new markets with the desired features in high demand. Being an Android devolper is a joy and seeing your apps used by many is an even bigger one. Happy coding.
- Android Portal at: http://www.android.com
- Google Play Store at: https://play.google.com
- Androidlet at http://www.androidlet.com
About the Author
Chunyen Liu has been a software professional for years. He was among winners at programming contests. He has been software co-patentee, written 30+ articles, reviewed books, and published apps at Androidlet and The J Maker. He holds advanced computer degrees, trained in 20+ graduate-level courses. On the non-technical side, he is a rated player, certified umpire, and certified coach of USA Table Tennis, winning State Games and US Open categorized doubles event previously.