Being Responsive

Android takes responsiveness very seriously.

Android enforces responsiveness with the Activity Manager and Window Manager. If either service detects an unresponsive application, it will display the dreaded "Sorry! Activity is not responding'' message — often reported by users as a Force Close error. This is shown in Figure 2-9.

This alert is modal, steals focus, and won't go away until you hit a button or your application starts responding. It's pretty much the last thing you ever want to confront a user with.

Android monitors two conditions to determine responsiveness:

> An application must respond to any user action, such as a key press or screen touch, within five seconds.

> A Broadcast Receiver must return from its onReceive handler within 10 seconds.

The most likely culprits in cases of unresponsiveness are network lookups, complex processing (such as the calculating of game moves), and file I/O. There are a number of ways to ensure that FIGURE 2-9 these actions don't exceed the responsiveness conditions, in particular by using Services and worker threads, as shown in Chapter 9.

The ' ' Force close' ' dialog is a last resort of usability; the generous five-second lit is a worst-case scenario, not a target. Users will notice a regular pause of anything more than half a second between key press and action. Happily, a side effect of the efficient code you're already writing will be more responsive applications.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment