Fragments, Tab Adapter, and Different Layouts

tabs_fragWhen using Fragments in tabs, the FragmentManager takes care of instantiating, retaining, and reusing Fragments.  The problem there is that a tag for a fragment is auto-generated.  If we want to reuse that exact Fragment in a different layout (like when the device is rotated), we need to extract the tag and use the same one when re-initializing.

The better way to do this is to create your fragment instance and tag yourself.  That way, you can easily get a reference to your fragment later from the fragment manager.

So essentially we need to replicate the inner workings on fragment pager adapter and explicitly add your fragment (and your tag).

Jake Wharton has a great code sample that demonstrates this for using a Fragment Pager Adapter.  Building off that, I combined the Fragment Pager Adapter code with a standard Tab Adapter.

Check it out on GitHub!

New App Engine Pricing may kill Earthquake Alerter

To send immediate alerts of earthquakes to users of my Android app Earthquake Alert, I use Google App Engine as the processing backend for C2DM (cloud to device messaging).  Since this was recommended by the Google Android team, I thought it would be a great option.  However that all changed when Google changed their pricing model for App Engine. Continue reading

Earthquake notifications using C2DM and App Engine

ea_customIn order to enhance my Earthquake Alert! Android app, I wanted to be able to alert any user’s phone when an earthquake occurs anywhere in the world that matches some pre-defined filters.  The end result was the Earthquake Alerter add-on app and it uses Google’s C2DM and Google App Engine to accomplish.  This post describes how I accomplished this. Continue reading

Japan Quake Visualized on Earthquake Alert!

I’ve always been fascinated with Earthquakes.  This fascination lent itself well once I began writing Android apps.  I was able to combine my interests and create Earthquake Alert!, an app that give users a great way to view and explore earthquakes all around the world.  As an active user of the app myself and testing push notifications, I was one of the earlier people to be aware of the Japan quake off the coast of Honshu.

Continue reading

Border Wait gets mini UI overhaul

Border Wait Android app was my first app and it showed – basic ListView, simple icons, and a launcher icon I found from the web.

For my fantasy football app Draft Punk, I used a number of new UI patterns I had seen in the official Twitter App and read on the Android Developer’s blog including the dashboard and action bar.  The result was my best looking app to date and a number of positive user reviews mentioning the interface and graphics.

So after finishing Draft Punk, it was time to revisit the look, feel, and graphics of Border Wait.

Continue reading

Android Tabs with interacting map and list views

Last tutorial, we wrote a simple app that displays two interacting list views in a TabActivity. In this tutorial, we will up the ante and add a MapView as the content of one of the tabs. Why again are we using multiple views in an activity instead of using a separate activity for each tab content? Remember, we want our tabs to be able to easily interact with one another, and keeping them as views allows us to handle the logic and interaction within one activity.

So, our goal in this tutorial is to have a list of geo coordinates and when we click on an item in the list, our map view goes to that location.
Continue reading