Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, February 11, 2011

Contacts Contract: Intro and Getting Started

If you've been using Android awhile, and have used the Contacts feature at all, you may have noticed that when you push your SDK forward a few versions, many of the calls are now listed as deprecated.

This is because the Android project revamped how the contacts system works in Android 2.0 (API Level 5). The updated system is much more flexible, while also taking a bit more code to use properly. Over at Mobiletuts+, we wrote an article quite a while back that has a quick overview of using the new APIs in context of using the contact picker. Android Essentials: Using the Contact Picker demonstrates how the queries are now often broken up due to increase in the number of internal tables used (or, that's mostly likely the cause).

You can also directly view the open source code for this tutorial.

Tuesday, February 1, 2011

New Feature: Book Code Downloads

Many readers have found it difficult to access the book code downloads from the official publisher site. After some discussion with our editor, we are pleased to inform you that we now have them hosted separately and available for easy, direct download. (No login should be needed and certainly no verification that you own the book. But you already bought it, right? :) )

In addition to providing a new source for downloading the files, we have also provided a single download for all of the code for each book.

The download link is convenient found right next to the Home link above, under "Book Code Downloads."

Happy Android Coding!

Tuesday, January 18, 2011

Phrasebook Map Intents: Redux

Maps 5.0 at 1024x600 (click)
Zoomed all the way out at z=2
As part of a review of some of our applications we've created as part of articles, we revisited the Phrasebook app found on Google Code. Written with Android 2.2 in mind, the application still runs fine on both Android 2.3 and with Tablet displays (e.g. 1024x600).

However, one strange issue did come up: the geo URLs for the addition of launching maps from Android SDK Quick Tip: Launching Maps In-App don't all work as expected with Maps 5.0. The default one, the world link, used:

geo:0,180?z=1

Sending this actually causes Maps 5.0 to crash. It works fine in Maps 4.2 and 4.7 (available in Emulator 2.2 and 2.3, respectively). The fix? Change z to 2. This is odd, because 1 is documented by Google to show the whole world. (Though, there is a note that the geo URI is still under development. The linked-to document is from 2007, though.) We clearly see in the above screenshot that there are no levels of zoom farther out now.

Next, we wanted to test the rest of the queries to see if any others were affected. Here they are, and the results:

"geo:0,0?q=Belgium": Success
"google.streetview:cbll=46.813812,-71.207378&cbp=1,99.56,,1,-5.27&mz=21": Success
"geo:0,0?q=Matterhorn&z=8": Success
"geo:0,0?q=Coffee Shops near Paris, France":Success

So, it's reasonable to expect the only thing to now avoid are zoom levels of 1. The fix has been pushed up to the repository.

This experience is a great example of the sort of maintenance applications can take. Not only should they be tested on devices with new firmware and SDK versions, but any other applications that they rely on also need to be updated and tested against. Maps 5.0 is not yet found within an emulator, so this testing requires a handset with Maps 5.0 on it.

Friday, September 17, 2010

Building an Android Application: Book Excerpt

Sometimes publishers allow sites to publish entire chapters of books. ComputerWorld recently published a complete chapter from Sam's Teach Yourself Android Application Development in 24 Hours. We think this is a particularly good excerpt, too, as it has broad topic coverage.

This excerpt, from Hour 3, covers topics from application design to resources to Android Activities. And then it goes on, and covering Activity lifecycle and even Intents and various things you can do with them as a developer. You even get information about debug logging. It's not just a preview of Hour 3, it's nearly the whole chapter.

Check it out at ComputerWorld!

Tuesday, September 14, 2010

¡Hola! Writing Android Apps for Different Languages and Locales

Find out how this
screen is localized!
It's easy to write Android applications in multiple languages and locales. By clever storage of localized resources in specially named project directories, most of the work in application internationalization is done for the developer. Whether you want to write an application that supports English and French, or Austrian German vs. Swiss German, you can learn how in our tutorial on Mobiletuts+.

Resources need not just be strings, either. Learn how to localize and internationalize your strings, colors, images, and more in Android SDK: Building a Localized Phrasebook.

Monday, August 23, 2010

Unit Testing with Android JUnit

Mobiletuts+ Android JUnit Testing Article
Testing is an important part of any software project. Testing for mobile is no different. One way of ensuring correctness of code at all levels is via automated unit testing.  Through automated unit testing, you can define expected results on the normal cases, in addition to edge case failures, standard failures, and everything in between. The popular JUnit framework is often used when writing these unit tests for Java.

The Android framework includes powerful unit testing support. Learn how to get started with Android JUnit with our Mobiletuts+ article on JUnit testing with Android.

Sunday, November 1, 2009

Android 2.0 & Droidcon!


It seems like we were justing about Android 1.6. Oh, wait, we were! Well, we have to admit: Android 2.0 is a little underwhelming from the developer point of view. It seems more like Android 1.7. Still, it's great progress and items like the account manager for using multiple accounts across the handset will be great for users and developers alike.

One item we liked, especially since we're on the road this month attending conferences and checking out the Android phones available in Europe, is the built-in update abilities that simply add support for Android 2.0 instead of require a completely new installation and configuration. All we had to do was run the SDK and AVK manager, update to the latest and run the Eclipse updates to get the newest plugin and we were good to go with 2.0!

On code we've tested, we haven't noticed any new issues with 2.0. However, if you run across any issues with our book code, please let us know! Once we've returned from our travels, we'll do a more thorough evaluation--with one of the new Android 2.0 handsets.

We're on the road? That's right! We're just days away from Droidcon in Berlin! See you there!