Thinking Beyond the Application Boundaries

At times, the device may perform extraneous work that can affect your application, such as downloading a large file in the background while playing music from an online radio application. Will these heavy network-bound activities affect the application in any way? It depends. If your app needs a connection to the Internet and for some reason cannot connect, will it crash? What will happen? Knowing the answers to these questions means that you’re thinking beyond your application boundaries.

Not all apps are created equal — some good ones are out there, along with some bad ones. Before building or releasing your first Android application, ensure that you know the ins and outs of your application and anything that can affect it. Be sure that the app doesn’t crash when users perform routine tap events and screen navigation.

Building applications on embedded devices is much different from building them on a PC or Mac, and the reason is simple: The resources (memory and processor, for example) are limited. If the Android device happens to be a phone, its main purpose is to perform phone-like duties, such as recognizing an incoming call, maintaining a signal, and sending and receiving text messages.

If a phone call is in progress, the Android system treats that process as vital, whereas a downloading file in the background is considered nonvital. If the phone starts to run out of resources, Android kills all nonvital processes to keep the vital ones alive. A file can be downloaded again, but when a call is lost, it’s lost forever — you have to make that call again, which would only frustrate the user if the main purpose for purchasing the device was to have a phone. Your app might download a file in the background and the process gets killed — this is a scenario that you need to test. It can also happen if your phone encounters an area with a poor or non-existent wireless signal. If the connection gets dropped, your file isn’t downloaded.

Test for all possible solutions and have a safety guard for them. Otherwise, your app will be prone to runtime exceptions, which can lead to poor reviews from users at the Google Play Store.

technicalstuff.eps

Interacting with your application

To ensure that your app works, fire it up and play with its features. While your app is running, start another app, such as the browser. Visit a few sites, and then return to your app. Click any buttons related to your app to see what happens. Try all kinds of things to see whether you find outcomes that you didn’t consider. What happens if a user is interacting with your app and receives a phone call? Are you saving the necessary state in onPause() and restoring it in onResume()?

remember.eps Android handles the difficult task management for you, but it’s ultimately your responsibility to manage the state of your application.

Testing whether your application works

In the emulator, open the Silent Mode Toggle application from the launcher. You’ve already performed the first step in the testing process — making sure that the app starts!

After the app is open, check to see whether the phone is in Silent mode by looking for the small phone icon on the notification bar (refer to Figure 5-5).

Click the Toggle Silent Mode button to toggle the ringer mode. Did the application’s image change from the green phone to the silent phone (or vice versa)? Try various actions to ensure that your application works as expected. If you find a flaw, use the debugging tools featured in this chapter to help identify the issue.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset