Nearby Intersections on GOOG-411

It is amazing how much information can be displayed on even the smallest map, yet we sometimes forget that geographic content is not always available visually.

If you're out and about, you can call GOOG-411 and get local information about businesses. Now we've made it even easier to orient yourself without a map in front of you: call GOOG-411, ask for 'details', and in addition to the address and phone number of the business, we'll also point you to the nearest street intersection or adjacent streets.

You can try it now: call 1-800-466-4411, look up 'Google in New York', ask us for more 'details', and we'll tell you that our Chelsea office is 'near the intersection with West 16th Street'. Unless you're a seasoned New Yorker, this might very well save you from walking up or down a few blocks.

The nearby intersections are available for most businesses in the US and Canada. They are derived automatically by an algorithm written on 20% time by Googlers in New York and London. Tell us other ways you would want to use this new feature -- we hope to expand it to other products soon!

Calling all developers for Android Developer Challenge 2!

I'm excited to announce the second Android Developer Challenge (ADC)! The first challenge was a huge success with over 1,700 entries that resulted in 50 excellent winners. With the recent release of Android 1.5, as well as the availability of devices in multiple markets around the world, I'm pleased to announce the second ADC.

We've expanded ADC 2 to involve a very important part of the Android community—the users who will be running these applications. Users of Android-powered devices with Android Market will be able to download a special Android judging application and use it to download and rank applications submitted to the Challenge. The results from this round will determine the top ranking applications in each of the 10 categories. These top applications will then be ranked by a combination of users and a panel of Google selected judges through a similar process as the first round to determine the final winners.

I've already seen a lot of great apps on Android and I look forward to seeing even more innovative and unexpected cool apps that will come out of this Challenge! For more details on ADC 2, please see the official site. Start your engines and good luck!

Android Icon Guidelines

For our second post in our series on Android UI, we're releasing our Icon Design Guidelines and an Android Icon Templates Pack. These should make it a lot easier for you (or your designer) to develop all the icons your applications need, so they fit with the other icons in the Android environment.

The Icon Design Guidelines document describes how to design and export icons that fit within the Android framework. It includes a wealth of detail about icons in the Home screen, menus, the status bar, tabs, dialogs, and lists.

The Android Icon Templates Pack is a collection of template designs, filters, and settings that make it easier for you to create icons that conform to the general specifications given in this Guidelines document. We recommend downloading the template pack archive before you get started with your icon design.

The Templates Pack provides templates in Adobe Photoshop and Adobe Illustrator file formats, which preserves the layers and design treatments we used when creating the standard icons for the Android platform. You can load the template files into any compatible image-editing program, although your ability to work directly with the layers and treatments may vary based on the program you are using.

Lightning talks at Google I/O

Google I/O is approaching, and with over ten quality talks lined up, we should all strive to be attentive, avid learners. But for the last Android session of the conference, we thought it would be fun to unwind and open up the podium for lightning talks. This is where anyone can take the stage for six minutes and talk about anything. If you've done a cool hack involving Android, if you've devised a clever technique for a common problem, or even if you just want to get up on your soapbox for six minutes to appeal to your fellow developers, this is your time to be heard.

For those planning on attending Google I/O, we need you to submit and judge lightning talk proposals through a Google Moderator series we've set up. Please go ahead and start submitting your proposals. You only have 250 characters to describe the talk, which may be 110 more characters than you've been used to these days.

Voting is open from now until the moment the session starts. We'll take the eight highest rated talks and will call upon each speaker to take the stage. Remember you only have six minutes. Exceed that, and our security force tackles you off the stage. Thanks and see you all at I/O!

Google Sync Beta - Now for S60

We love to hear user feedback and one of the most common questions we get is, "When is this coming out for my phone?" Well, for those of you who have been asking about Google Sync for mobile on your Nokia S60 smartphone, we're happy to announce that you can now synchronize your Google Contacts and Calendars with your mobile device.

Google Sync offers two-way, over-the-air contacts and calendar synchronization. This means that you can make changes to your contacts and calendar on your phone or in your desktop Google account. Since Sync uses push technology, the changes should automatically appear within minutes. And your information is constantly syncing, so it's up-to-date and securely stored within your Google account, even if you lose your phone.


Please note: Google Sync for S60 requires Nokia software to be installed on the phone. We also recommend backing up your calendar and contacts before setting up Sync. To find out more about setting up Google Sync on Nokia S60 phones, please visit our help center.

To try Google Sync, visit m.google.com/sync from your desktop.

Posted by Jon Skeet and Douglas Gresham, Software Engineers, Google Mobile

The Iterative Web App - Gmail for Mobile Gets Labels

On April 7th, we announced a new version of Gmail for mobile for iPhone and Android-powered devices. Among the improvements was a complete redesign of the web application's underlying code which allows us to more rapidly develop and release new features that users have been asking for, as explained in our first post. We'd like to introduce The Iterative Webapp, a series where we will continue to release features for Gmail for mobile. Today: Labels. --Shyam Sheth, Product Manager, Google Mobile.

You asked for it, and we listened. We've added labels to Gmail for mobile on Android-powered devices and the iPhone. Labels in Gmail allow you to use color-coded tags to manage your inbox.



To label an email, select a message then tap 'Label as..." from the drop-down menu on the Floaty Bar. In the pop-up menu, select the label(s) you would like to use and tap 'Apply'. Please note, you can add and remove existing labels to your emails in Gmail for mobile, but labels can only be created, renamed and deleted in the desktop version.

To label your emails on the go, point your mobile browser to gmail.com on your iPhone or Android-powered device. To make it easy to check your Gmail, try creating a home screen link. The new Gmail for mobile supports iPhone/iPod Touch OS 2.2.1 or above, as well as Android-powered devices, and is available for US English only.

Posted by Heaven Kim, Product Marketing Manager, Google Mobile

Google Product Search for Android now with Barcode Scanning

Since we launched Google Product Search for mobile a few weeks ago, I've been using it to check prices, reviews and product details on my Android phone. In addition to typing in my product searches, I've also had some fun speaking them. Sometimes, though, when I'm looking up a specific item in a store rather than a category of products (like "bluetooth headsets"), I'd rather just scan a barcode to see results for the exact product I'm searching for. That's why we've integrated barcode scanning with Google Product Search for mobile.

Here's how to get started. First, visit the Google Product Search for mobile homepage by going to Google.com in your browser and selecting 'Shopping' from the 'more' tab. Next, tap on the 'Scan Barcode' button to install the latest version of the Barcode Scanner app -- if you don't already have it -- from Android Market.

After you've installed the application, go back to Product Search in your browser and tap on the 'Scan Barcode' button again. Select "Use by default for this action" and tap on the Barcode Scanner option. After the app opens, center the red line over the barcode and hold the phone steady. When the barcode is read successfully, you'll see a Google Product Search results page back in the browser.

You can also access the scanner directly from the top of the Product Search results page by tapping on the barcode button.

Today, barcode scanning works best for products like electronics, books, movies or video games, but we're working on adding more barcodes for other items. Of course, if your scan does not return a result, you can always type in the product name just as before.

The integration of Barcode Scanner and Product Search for mobile is available in the US and UK, for Android-powered devices.

Behind the scenes of the NYC - Google mapping partnership

(cross-posted with Google Lat-Long Blog)

In January New York City Mayor Michael Bloomberg announced a partnership between Google and NYC & Company, NYC’s official marketing, tourism and partnership organization, to create a new website and high-tech information center. Using these new tools, you can now plan a trip to NYC from your home computer, transfer your itinerary to your cell phone, and then learn more at an information center.

A number of people have asked us about our role in the NYC partnership. We did not create nycgo.com and the Official NYC Information Center here at Google, as you'd probably expect. Rather, we provided NYC with our standard APIs and a bit of technical guidance, and NYC did the rest.

To help other cities and organizations gain a bit more insight into how NYC managed to create nycgo.com and the Official NYC Information Center, we put together this short video of interviews with principal members of the NYC project team.



Click here to learn more about the partnership between Google and NYC.

Sky Map for Android - A Mobile Planetarium

I originally heard about Android on my first day at Google. A colleague and I were excited about all of the features that would be present in the platform, such as the GPS, compass, and motion sensors. As astronomy buffs, we talked about how cool it would be to use these features in a mobile application that would correctly display the sky based on your location and the direction you're facing.

Fast forward 12 months. We produced a "prototype" of the mapping application consisting of a phone, a compass, a level, and a map, and then convinced several others to join the project. Now that there was some excitement around the project, the real development could begin.


We were able to play around with a T-Mobile G1 test device in the office and were intrigued by all of the sensors that were available. The GPS and clock allowed us to generate maps for the exact time and location, but the compass and accelerometer were what made Sky Map truly interesting. Using these two sensors, the app can determine the exact direction that your phone is facing and display the stars that are visible. If you want to identify that bright star in the west, all you have to do is point the device in that direction and you'll see "Venus" appear on your screen.


Because we do work for Google, it was perfectly natural for us to add a search feature. We decided to use the location features in the Android platform to implement search in an easy-to-use way. You enter the name of an object of interest, like Saturn, and the phone displays an arrow pointing to the object. As you get closer, the color of the arrow goes from blue to red and the app circles the object when you find it. Voila!


This month is a great opportunity to do some planetary observing -- spot the elusive Mercury in the evening, see Jupiter and Neptune in same binocular field, or view Venus shining in the morning skies. Sky Map was designed to help you navigate the night sky, making months like this particularly exciting! Since 2009 is the International Year of Astronomy, there will be plenty of opportunity to show off the application to your friends.

Download Sky Map from the Android Market, and let us know what you think. We'd love to hear from you, both the good and the bad. You can leave comments here or in the Help Forum. 

Update: We have updated the version of Sky Map for Android in Android Market. We realize that some users were experiencing crashes or slow start-up times. This new version fixes these issues, so Sky Map should now work fine on all Android-powered phones. (May 13, 2009 10:10 pm PDT)

Kevin Serafini, Orbiting Software Engineer

YouTube uploads and more now available on Android

If there is one thing I've always wanted, that is to be able to record and share special moments in my life, anytime, anywhere. Needless to say, I am quite excited that I can now pick up my Android-powered phone, start recording videos left and right- and then even upload them to Youtube!

Video uploads is just one of several new Google mobile features and improvements in the new Android 1.5 release:
  • YouTube: record and easily upload videos to YouTube.
  • Picasa Web Albums: upload photos directly to your Picasa Web Albums.
  • Gmail: multiple-thread selection to easily archive, delete, label or mute several threads at once.
  • Search by voice: improved speech recognition.

I seem to always forget my video camera when there's a funny moment that I wish I could record (like my facial expression after tasting a durian for the first time). Now I don't have to worry about that! I can record and play back videos whenever I have my phone with me, and I can easily share them or upload them to YouTube directly from my phone. It's easy- just tap 'share' and select YouTube.



What's more, YouTube gives me full control of my privacy, so I can decide if I want to make my videos available to the entire Web or just a subset of invited friends.

This Android update also enables easier Picasa uploading by reducing the number of clicks needed to share your pictures with others. Just like YouTube- after taking a picture tap 'share' when viewing a photo and select Picasa.

As someone who uses Gmail on the desktop, I appreciate the new 'batch edit' functionality on Android. Instead of selecting and archiving dozens of emails on my phone, one email at a time, I can now select multiple Gmail conversations and act on all of them as a group, saving time for the more important stuff.


And last but certainly not least, we've made it even easier to search with your voice by improving speech recognition. I've personally been surprised and entertained by the cute pictures that appear in my search results when speaking "pictures of Pygmy Marmosets" - give it a try!


Painless threading

Whenever you first start an Android application, a thread called "main" is automatically created. The main thread, also called the UI thread, is very important because it is in charge of dispatching the events to the appropriate widgets and this includes the drawing events. It is also the thread you interact with Android widgets on. For instance, if you touch the a button on screen, the UI thread dispatches the touch event to the widget which in turn sets its pressed state and posts an invalidate request to the event queue. The UI thread dequeues the request and notifies the widget to redraw itself.

This single thread model can yield poor performance in Android applications that do not consider the implications. Since everything happens on a single thread performing long operations, like network access or database queries, on this thread will block the whole user interface. No event can be dispatched, including drawing events, while the long operation is underway. From the user's perspective, the application appears hung. Even worse, if the UI thread is blocked for more than a few seconds (about 5 seconds currently) the user is presented with the infamous "application not responding" (ANR) dialog.

If you want to see how bad this can look, write a simple application with a button that invokes Thread.sleep(2000) in its OnClickListener. The button will remain in its pressed state for about 2 seconds before going back to its normal state. When this happens, it is very easy for the user to perceive the application as slow.

Now that you know you must avoid lengthy operations on the UI thread, you will probably use extra threads (background or worker threads) to perform these operations, and rightly so. Let's take the example of a click listener downloading an image over the network and displaying it in an ImageView:

public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
Bitmap b = loadImageFromNetwork();
mImageView.setImageBitmap(b);
}
}).start();
}

At first, this code seems to be a good solution to your problem, as it does not block the UI thread. Unfortunately, it violates the single thread model: the Android UI toolkit is not thread-safe and must always be manipulated on the UI thread. In this piece of code, the ImageView is manipulated on a worker thread, which can cause really weird problems. Tracking down and fixing such bugs can be difficult and time-consuming.

Android offers several ways to access the UI thread from other threads. You may already be familiar with some of them but here is a comprehensive list:

Any of these classes and methods could be used to correct our previous code example:

public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
final Bitmap b = loadImageFromNetwork();
mImageView.post(new Runnable() {
public void run() {
mImageView.setImageBitmap(b);
}
});
}
}).start();
}

Unfortunately, these classes and methods also tend to make your code more complicated and more difficult to read. It becomes even worse when your implement complex operations that require frequent UI updates. To remedy this problem, Android 1.5 offers a new utility class, called AsyncTask, that simplifies the creation of long-running tasks that need to communicate with the user interface.

AsyncTask is also available for Android 1.0 and 1.1 under the name UserTask. It offers the exact same API and all you have to do is copy its source code in your application.

The goal of AsyncTask is to take care of thread management for you. Our previous example can easily be rewritten with AsyncTask:

public void onClick(View v) {
new DownloadImageTask().execute("http://example.com/image.png");
}

private class DownloadImageTask extends AsyncTask {
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}

protected void onPostExecute(Bitmap result) {
mImageView.setImageBitmap(result);
}
}

As you can see, AsyncTask must be used by subclassing it. It is also very important to remember that an AsyncTask instance has to be created on the UI thread and can be executed only once. You can read the AsyncTask documentation for a full understanding on how to use this class, but here is a quick overview of how it works:

In addition to the official documentation, you can read several complex examples in the source code of Shelves (ShelvesActivity.java and AddBookActivity.java) and Photostream (LoginActivity.java, PhotostreamActivity.java and ViewPhotoActivity.java). I highly recommend reading the source code of Shelves to see how to persist tasks across configuration changes and how to cancel them properly when the activity is destroyed.

Regardless of whether or not you use AsyncTask, always remember these two rules about the single thread model: do not block the UI thread and make sure the Android UI toolkit is only accessed on the UI thread. AsyncTask just makes it easier to do both of these things.

If you want to learn more cool techniques, come join us at Google I/O. Members of the Android team will be there to give a series of in-depth technical sessions and answer all your questions.

New BlackBerry Enterprise Server Packages for Google Mobile applications

This week a few of us are at RIM's Wireless Enterprise Symposium to talk with BlackBerry administrators about Google Mobile. Last night we announced the Google Apps Connector for BlackBerry Enterprise Server (BES). Today we're excited to announce the availability of new enterprise installation packages for Google Mobile App and Google Maps for mobile.

These enterprise installation packages allow BlackBerry administrators to deploy Google Mobile applications to corporate BlackBerry phones. Administrators have the option of using ALX packages to push applications to BlackBerry phones through BES. Alternatively, administrators can host JAD/COD packages on a private intranet so that employees can download applications from internal sites. BES administrators will need to configure their BlackBerry phones to allow applications from Google to be installed.

The ability to quickly search for information outside of the office is useful to workers on the go. With Google Mobile App, employees can search by voice, or otherwise quickly type queries by selecting query suggestions or past queries in their search history. Users can search for anything they can find on Google, such as stock quotes, product information, or weather. Google Mobile App also enables local search thanks to My Location -- just try searching for "pizza" or "hotel". Google Mobile App conveniently launches Google Maps, where it it is easy to get driving, transit, or walking directions.

If you're a BlackBerry administrator who is interested in deploying Google Mobile applications in your business, learn more at http://mobile.google.com/enterprise

Posted by Ryan Pollock, Product Marketing Manager

Drawable mutations

Android's drawables are extremely useful to easily build applications. A Drawable is a pluggable drawing container that is usually associated with a View. For instance, a BitmapDrawable is used to display images, a ShapeDrawable to draw shapes and gradients, etc. You can even combine them to create complex renderings.

Drawables allow you to easily customize the rendering of the widgets without subclassing them. As a matter of fact, they are so convenient that most of the default Android apps and widgets are built using drawables; there are about 700 drawables used in the core Android framework. Because drawables are used so extensively throughout the system, Android optimizes them when they are loaded from resources. For instance, every time you create a Button, a new drawable is loaded from the framework resources (android.R.drawable.btn_default). This means all buttons across all the apps use a different drawable instance as their background. However, all these drawables share a common state, called the "constant state." The content of this state varies according to the type of drawable you are using, but it usually contains all the properties that can be defined by a resource. In the case of a button, the constant state contains a bitmap image. This way, all buttons across all applications share the same bitmap, which saves a lot of memory.

The following diagram shows what entities are created when you assign the same image resource as the background of two different views. As you can see, two drawables are created but they both share the same constant state, hence the same bitmap:

This state sharing feature is great to avoid wasting memory but it can cause problems when you try to modify the properties of a drawable. Imagine an application with a list of books. Each book has a star next to its name, totally opaque when the user marks the book as a favorite, and translucent when the book is not a favorite. To achieve this effect, you would probably write the following code in your list adapter's getView() method:

Book book = ...;
TextView listItem = ...;

listItem.setText(book.getTitle());

Drawable star = context.getResources().getDrawable(R.drawable.star);
if (book.isFavorite()) {
star.setAlpha(255); // opaque
} else {
star.setAlpha(70); // translucent
}

Unfortunately, this piece of code yields a rather strange result, all the drawables have the same opacity:

This result is explained by the constant state. Even though we are getting a new drawable instance for each list item, the constant state remains the same and, in the case of BitmapDrawable, the opacity is part of the constant state. Thus, changing the opacity of one drawable instance changes the opacity of all the other instances. Even worse, working around this issue was not easy with Android 1.0 and 1.1.

Android 1.5 offers a very way to solve this issue with a the new mutate() method. When you invoke this method on a drawable, the constant state of the drawable is duplicated to allow you to change any property without affecting other drawables. Note that bitmaps are still shared, even after mutating a drawable. The diagram below shows what happens when you invoke mutate() on a drawable:

Let's update our previous piece of code to make use of mutate():

Drawable star = context.getResources().getDrawable(R.drawable.star);
if (book.isFavorite()) {
star.mutate().setAlpha(255); // opaque
} else {
star. mutate().setAlpha(70); // translucent
}

For convenience, mutate() returns the drawable itself, which allows to chain method calls. It does not however create a new drawable instance. With this new piece of code, our application now behaves correctly:

If you want to learn more cool techniques, come join us at Google I/O. Members of the Android team will be there to give a series of in-depth technical sessions and answer all your questions.

Use Google Apps seamlessly with corporate BlackBerry smartphones

If your employer has provided you with a BlackBerry smartphone, you may be accustomed to its built-in email, calendar, and address book applications. The Google Apps Enterprise team has just announced that we will soon release Google Apps Connector for BlackBerry Enterprise Server, which enables you to use these familiar applications with Google Apps.

Google Apps is our hosted solution for enterprise messaging and collaboration. It includes Gmail, Google Calendar, and more. Google Apps Connector for BlackBerry Enterprise Server connects your BlackBerry Enterprise Server directly to the Google cloud, and creates a seamless experience between Google Apps and the built-in BlackBerry smartphone applications for mail, calendar, and address book. The Google Enterprise blog has more details about the offering.

If you're an IT administrator interested in Google Apps, you should know that Google Apps Connector for BlackBerry Enterprise Server is currently in beta testing with select companies and universities. We are targeting a July 2009 release for Google Apps Premier and Education Edition customers, at no additional cost. This week we're at the Wireless Enterprise Symposium, so if you happen to be at WES, come visit us at Booth #105. We'll also be talking about Google Apps and other Google Mobile products at our breakout session tomorrow, so we hope to see you there!

Posted by Hong Zhang, Software Engineer




Do more with Google Latitude!

When we launched Google Latitude a couple of months ago, we were flooded with feature suggestions. One frequent request was to allow you to share your location with even more people and not just your Latitude friends. Today, we're launching two applications that do just that!
  • Google public location badge lets you publish your Latitude location on your public website or blog. You can just embed the standard badge -- like this or you can use the KML or JSON feeds directly. Read more about the badge on our Blogger Buzz. When you enable this application, your location will be shared publicly and you will not be able to control who can or cannot see it. For your privacy, you may choose to share your best available location, share only your city-level location, or simply never enable the badge.
  • Google Talk location status (beta) lets you share your Latitude location with all your Gmail chat and Google Talk contacts. It will automatically update your status message to your current city as you move, and anyone who can chat with you will be able to see this location status. Of course, you can easily change back to your custom status message at any time.

Visit google.com/latitude/apps to enable these applications. They are two separate apps, so you can select which one(s) you'd like to use and customize exactly how you'd like to share your Latitude location. You must be an existing Google Latitude user; if you're not already, you can sign up here!

Please note that we take your privacy very seriously, and your location will not be shared with any application without your consent. Both apps adhere to the same terms and conditions -- you must explicitly opt in to the application and of course, you can always disable an app by going back to the app's page.


These applications are only available in the US for now, but they'll soon be ready for all the same languages and countries that Google Latitude supports.

Hope you enjoy these, and stay tuned for more Latitude goodies. Also, we love feedback, so please tell us what you think in our Help Forum or suggest ideas for apps on our Product Ideas page (be sure to include "Latitude" so we can search for them!).

Rohan Seth, Software Engineer, Google Mobile