Thursday, January 27, 2011

Android app life cycle and the HOME and BACK keys

As I'm working on adding the option in Net Ping that allows continuous pinging, I've had to take a closer look at the Android app life cycle. Or, I should more accurately say, the Android activity life cycle. Android apps are a stack of Activities.

Here is the diagram from the Android developer documentation:

Activity life cycle, from android.com.
I had observed different behaviors from when I used the BACK key to return to the home screen versus the HOME key. I'm testing on Android 2.2.

If the user presses HOME, the activity is paused, and then stopped. If the user presses BACK, the app is paused, stopped, and destroyed. As an Android user, the distinction was never obvious to me. That's probably because most apps get it right.

Net Ping starts the ping in the background in order to keep its main activity responsive. Now that the unpublished, development version of the app can ping forever, stopping the ping when the app is paused has become important. If I don't stop pinging, the user can lose control of the operation, and ping will continue to run and drain the battery until the phone is restarted. The biggest surprise was that Force Closing Net Ping didn't kill the ping operation.

For all situations I've observed, the activity is paused and resumed. Net Ping has to be able to pause and resume the ping operation in these events. Once I finish proper pause/resume handling, I'll publish an update to Net Ping.

In my testing, I noticed two other cases of importance. When the Settings screen is activated by the user, the user is presented with the Settings activity, and the main activity is paused. This is the same behavior as if the user pressed the HOME key. Secondly, when the device orientation changes, the main activity is destroyed and recreated in the new orientation, much like pressing BACK and starting the app again.

To summarize, the scenarios that any app that performs background processing should gracefully handle are as follows:

All situations:

  • Pause/Resume/Create.

Activity is stopped, but not destroyed upon:

  • HOME key press.
  • Transitioning to a different activity, like Settings.

Activity is stopped and destroyed upon:

  • BACK key press.
  • Orientation changes.

Monday, January 24, 2011

Net Ping and option -t

On the Android Market, Andrew wrote:

"Very, very nice! Please add option ( -t )!"
Thanks for the feedback!  I think you mean the -t option that the Windows version of ping offers, which pings continuously until stopped.

The Linux version of ping uses -t to specify ttl, which Net Ping does as of version 1.2.

I wasn't sure if continuous ping on an Android phone would be useful, but it's not too difficult for me to add in.  My plan for continuous mode is to ping until you stop (via the menu), or hide the app (like going to the home screen). I don't want Net Ping inadvertently draining  batteries.

Thursday, January 20, 2011

Net Ping, parameters, and preferences

I'm refining the changes to Net Ping that will allow users to change the parameters for pinging.

The preference framework that the Android SDK provides is pretty good for quick, generic app preferences. For a more polished user experience, the developer should put more work into the code.

Here is a screen shot of the preference screen in my development build.

Before I update to the Market, I have these things to wrap up:


  1. Force the preference screen to get updated values when Reset is used.
  2. Add a Go/Stop menu option on the main screen.  Now that the user can potentially start a very long-running ping operation, we need a way to stop it.
  3. Present the numeric keyboard (instead of the alpha one) for these options.  The alpha keyboard appears by default now, and it's a little annoying to have to switch manually.
  4. And, of course, testing.


Friday, January 14, 2011

Android app error reporting for Net Ping

As Net Ping approaches 1000 downloads, I'm intrigued that there have been no error reports collected by the app's development console. Version 1.1 of Net Ping is designed to allow general, unanticipated errors to display the "Force Close" message. Users can optionally submit a report about the crash to the developer (me.)

Net Ping for Android's Error Report

I imagine if Net Ping was force-closing too much, error reports would have been collected already. I think this indicates a nice platform consistency across the Android devices.

I'm working on the adding the option to control the parameters of ping, based on user feedback. I should have that update out in a few days.

Tuesday, January 11, 2011

Net Ping and parameters

In version 1.1 of Net Ping, I don't give the user any way to change the parameters of the ping operation. You can't change the number, size, interval, and so on of the ping packets.

I wasn't sure if this was something users would want. I indeed have gotten feedback that this is something users could use.

I like the simplicity of how Net Ping works. I'd like to keep it quick and easy to use, so for those who would like to change the parameters, I'll add a Settings menu option to allow adjustments to the ping parameters for an update, soon.

Thanks for the feedback!

Sunday, January 9, 2011

Net Ping has been updated.

Net Ping is now at version 1.1.

Keyboard Improvements

With the soft keyboard, I changed the action key to be "Go" instead of "Done." Pressing Go will dismiss the soft keyboard and start the ping.

Also, if the soft keyboard is using the whole screen (landscape mode), then the action button, in the upper right corner, is labeled "Ping." This gives a more polished feel to the app when using the landscape soft keyboard.

On the hard keyboard, the return key will start pinging, too.

Error Messages

If the underlying platform can't execute the ping, there is an error message will be output.

Also, if the system's security settings prevent the ping operation, a special security message will appear.

Friday, January 7, 2011

Coming improvements for Net Ping

I have two things in mind that I want to change about Net Ping:
  1. On the keyboard, let the return key start the ping.
  2. Add an informative message if Net Ping can't perform the ping.
I was using the touch keyboard mostly for testing of the app, and I chose the IME (Input Method Editor) option to display a "Done" button instead of a return key. Kudos to my buddy Mitch noticed my mistake on his Droid, because he's used to the slide out keyboard.

After seeing the "no workee" comment on the app, I've been trying to imagine what didn't work about the app. I think there is code path where ping may not work, but no output is generated. I'll add a message in that path.

I appreciate all comments. If my app isn't working as you expect, I want to get your feedback so that I can make it right. It's more helpful if the comment has information on what went wrong.

If the comment doesn't have enough space, comment on this blog or send an email through the Android Market.

Big thanks to everyone who took the time to install the app, and those those rated and commented!