Tuesday, November 23, 2010

Android Applications I Use

Putting the applications I write aside, here's a list of the Android applications I have installed in no particular order. Applications in bold are used often. I'll try to get back to this list and update with descriptions or links.

  • Amazon
  • Angry Birds
  • Autozone
  • Barcode Scanner
  • Chrome to Phone
  • Congress
  • eBay
  • Epicurious
  • Facebook
  • Google Finance
  • Google Gesture Search
  • Google Gmail
  • Google Goggles
  • Google Buzz
  • Google Search
  • Google Sky Map
  • GPS Status
  • Hotspot Widget
  • IMDb
  • Google Maps
  • Mileage
  • Mint.com
  • Google My Tracks
  • Flixster
  • OBD II Reader
  • OpenSpark
  • Overstock
  • Pandora
  • Photoshop
  • ESPN Scorecenter
  • Shazam
  • Google Shopper
  • ShopSavvy
  • StopWatch & Timer
  • Swype
  • Target
  • The Weather Channel
  • Torque
  • Transdroid
  • Twitter
  • Urbanspoon
  • Google Voice
  • Google Voice Search
  • Wordpress
  • WRAL.com
  • XBMC Remote
  • z4Root

Thursday, November 18, 2010

New Phone - LG Optimus S


My previous phone, the HTC Hero was once considered high-end for an Android phone. Back then, there wasn't much for choices, the Hero followed the HTC G1, and roughly matched the functionality of the MyTouch.

Today there are a wide variety of phones from junk to super high-end. I envy the owner's of the HTC EVO 4G, but it's difficult for me to justify the $200 up-front + $240 in additional fees over the 2 year contract. RadioShack and Sprint recently offered a promotion for the new low-end LG Optimus S for $0, no rebate required. That's $440 cheaper over 2 years than the EVO.

I took the plunge, and I'm delightfully surprised at just how nice the Optimus S. In many ways it's a big upgrade from my HTC Hero, but with a few caveats. Here's the quick rundown.

Improvements:
  • Stock Android 2.2.1 - Froyo tastes great.
  • Faster CPU. The 600mhz CPU is a big improvement, even beyond raw numbers.
  • GPU. Added acceleration for graphics. I can play Angry Birds now.
  • Slightly thinner, smaller.
  • More responsive touch screen.
  • Dedicated 2-stage camera button.
  • Dedicated voice dialer button.
  • No blinding notification light while charging
  • Proximity Sensor turns phone screen on and off automatically when calling.
  • Very fast and accurate GPS
  • Swype keyboard included free
  • Can be rooted.
  • Only Sprint app is SprintID. No junk.
  • Wireless hotspot capability
Drawbacks:
  • No notification light for SMS, Email, Missed Calls, etc.
  • No trackball. Made text editing a bit easier.
  • No light sensor. Screen brightness is fixed to your setting.
  • No dedicated dial and hang up button. Not really necessary on this phone.
  • Low-resolution 480x320 screen.
  • New Phone and Brand - No community for custom ROMs yet.
  • SprintID is confusing and an annoying addition.
  • The Google first time use wizards have been removed. I found these helpful as an experienced Android user and they were certainly helpful to new Android users.
  • I can't tell if the Google Backup facility is there. If I reset, will my apps automatically reinstall?
Bugs:
  • Included SD Card randomly mounts/remounts. I replaced mine with an 8GB and this problem has never occurred.
  • Can't set voicemail provider in settings. I tried to set it as Google Voice, but there's no option. So far this has had no functional drawbacks, but I like to do it "right".
Coming from a Hero, I can handle those drawbacks and gladly accept the improvements.

Wednesday, April 7, 2010

Android Widgets, the Lowest Common Denominator

I should be nicer, modern smartphones are meant to be intuitive and user friendly, but they're more powerful than ever and with that comes complexities. As such, some people just don't know how to use an Android widget. They see them, they may have even used them before, but they don't know how to use yours.

What am I talking about? If you've written a Widget only application for Android, you may have encountered some baffling negative feedback; users complaining that the application just doesn't work. In their defense, it might not entirely work. After downloading an application from the Market, the user may encounter an installation complete screen with a button to launch the newly downloaded application. In the latest versions of Android, if there's not an Activity defined to handle the MAIN intent, the button is grayed out. But in older versions, I've confirmed 1.5, that button is not grayed out. When the user clicks the button, an error is displayed.

Another way the user may encounter the same problem is from the notifications area. A notification is made indicating that the application installed successfully. When tapping on this notification the application is launched. Again, without a main activity, on older versions of Android, this will result in an error.

It may seem obvious to you that you've developed an application, and the user should add it to their home screen by pressing 'Menu' from the home screen and following the menus to add a widget. Unfortunately, it's not obvious to everyone. So here's the easy work-around. Create a basic layout with just a TextView. Fill the TextView with some instructions as to how a user should add the widget to their home screen. Extend Activity and create a dumb Activity class that sets the content view to the instruction layout. Finally, register this new Activity in your AndroidManifest as the consumer of the MAIN intent.

Instead of encountering an error, the user is confronted with obvious, yet helpful instructions. Hopefully you'll encounter a happier commenter as the result of these simple changes.

Thursday, April 1, 2010

San Francisco, CA Muni Bus Locator

The Muni Bus Locator allows you to stay inside until the bus is outside. Select a route, and the route, buses, and stops are drawn on an interactive map. Click a bus to see it's speed and status. Zoom in to see individual stops. Select a stop to see the predicted next arrivals. Press the menu button to select another route, or change map mode mode from Map to Satellite.

Search the Market for: Muni Locator

Or... Click/Scan the QR code below:

Monday, March 29, 2010

Avoiding ConcurrentModificationException in MapView.draw()

Throwing this out there because it may help someone. For whatever reason, you may have gotten the idea that you would like to add and remove Overlays to your MapView as you see fit. Problem is, that MapView may be iterating through that List when you pull the rug out from under it and remove something from that List. Adding is okay of course.

Here's my advice, don't ever remove from it. Just render it ineffective. You may find it best to just empty the collection that backs your ItemizedOverlay. Or override draw() and add a hook to return early without doing anything in a particular circumstance. Of course, to do any of this you'll need to maintain a handy reference to the Overlay you add.

So remember, it's okay to call mapView.getOverlays.add() at any time, but don't call mapView.getOverlays.remove(), because if the timing is off, it will blow up on you.

While I'm writing this, I was thinking, you may be able to call remove(), by first disabling your MapView. That's worth a shot if it works in your scenario.

ItemizedOverlay and ArrayIndexOutOfBoundsException

If you're working with Google's Maps API on Android, you've probably encountered an ArrayIndexOutofBoundsException in ItemizedOverlay. To recap, ItemizedOverlay is a useful implementation of Overlay that displays a set of items on the map. More often than not, your data is dynamic, and this set of items will grow or shrink over time. It may even be an empty set.

The ArrayIndexOutOfBounds exception is usually encountered because you've done one or more of the following:
  • Overlayitem getItem(int position) returns null in your ItemizedOverlay
  • The set of items is empty (related to above).
  • You're concurrently modifying your backing Collection of OverlayItems while the draw() method is iterating through them.
Let's quickly look at a solution for each one of these. The first is for you to solve. Why is it returning null? Debug your code.

I've read some crazy ideas about how to solve the 2nd problem, your backing collection is empty, and ItemizedOverlay pukes. This is very easy to workaround. Override the draw() methods, and return early. Here's an example:


public boolean draw(Canvas canvas, MapView mapView, boolean shadow,long when) {
if (myBackingList.isEmpty()) {
return false; // False means there's no need to immediately redraw.
}
}

Finally, it's important to know that when ItemizedOverlay is executing the draw() methods, it's actually looping through your Collection of OverlayItems by calling getItem() and size(). During this time it would be unwise to modify the collection. Your first instinct is probably to use a synchronized collection or call Collections.synchronizedList (or whichever is appropriate). But this probably won't help because ItemizedOverlay isn't calling the iterator on your collection, it doesn't know what your collection is. Instead, it's calling getItem(), N times.

The approach that works is to synchronize access to your collection in getItem(), size(), and and your call to super.draw(). Additionally, you'll need to synchronize wherever in your code you modify the collection.

So to wrap up, make sure you override draw() to handle the empty set scenario and synchronize access to your backing collection.

Good luck!

Wednesday, March 10, 2010

R-Line App without Ads

Just to prove that I'm not a full-on ad-whore, I've removed the ads from the R-Line. After all, it is for my home town. Enjoy!