Pivotal Android Tidbits 06/07/2011

June 8, 2011 Joe Moore

We’re trying an experiment: since we currently have several Android projects at Pivotal Labs, and Android development and testing is hard, we are going to post to the blog the tips, tricks, gotchas, and conundrums we find.

Emulator and Orientation

Android will destroy and recreate activities upon screen orientation change. One way to prevent this is to set android:configChanges="orientation" in your AndroidManifest.xml (article here):

<activity android:name=".activities.MyActivity"
          android:configChanges="orientation"/>

This prevents android from calling onPause() => onDestroy() => onCreate() on a device, but not within the emulator; annoyingly, the Activity is still recreated within the emulator.

Un-shadowed Method Warnings?

Once again we spent about 15 minutes debugging a failing unit test only to find that there was no Robolectric implementation/shadow for one of the Android methods under test (ArrayAdapter#insert in our case). I would be nice to have a “warning mode” where Robolectric would log warning for all un-shadowed methods. I wish we knew the guys who wrote Robolectric…

About the Author

Biography

More Content by Joe Moore
Previous
NetworkedHelpDesk.org: New standard for data sharing
NetworkedHelpDesk.org: New standard for data sharing

Pivotal Tracker is a founding member of NetworkedHelpDesk.org, a new initiative to help "create a seamless ...

Next
Innovative solutions in Healthcare @ AppsforHealth Challenge
Innovative solutions in Healthcare @ AppsforHealth Challenge

On Friday May 27th and Saturday May 28th, Mohawk College hosted the first annual AppsForHealth challenge fo...

Enter curious. Exit smarter.

Learn More