Thursday, August 22, 2013

Update rolling out to new Nexus 7, claims to fix multitouch issues

When the second generation Nexus 7 was launched, it was plagued with many problems. Factory images weren’t being released, people complained about multitouch issues and the GPS cut out for many. Google seems to have worked hard to make the device better, and the first two issues have been fixed. Previously, Google posted the factory images for the device on their site.
Today, they’re beginning to roll out a new update for the tablet. The update is Android build JSS15Q and is made specifically to fix the multitouch issues many people experienced. And though not everyone has received it, there are already reports that it does indeed fix the issue!
People had many theories about why these issues were present, but it was probably something as simple as a bad undervolt on the touchscreen controller. That’s why it worked better plugged in; it received the proper voltage. We’re glad to see the update fixing people’s issues without the need for an RMA. Have you received this update? Did it fix your issues?

Google Play Services 3.2

We've just finished rolling out the latest release of Google Play services to devices around the world. It offers better performance and greater power savings, as well as enhancements to the Location Based Services, maps, InstantBuy, Google+, and Photo Sphere.
To simplify your testing, we've also released an updated Google APIs emulator image that includes Google Play Services 3.2. You can download the image through the Android SDK Manager.

Maps and Location Based Services

Google Play Services 3.2 includes several enhancements to the Location Based Services. The Fused Location Provider now supports the selection of a low-power mode option when requesting location updates, and the ability to inject mock locations — allowing you to more efficiently test your apps in a variety of simulated conditions.
The geofencing APIs have been updated to support hardware-based GPS geofencing on devices that have supporting hardware, such as the Nexus 4. Hardware geofences consume significantly less battery, and best of all your app will automatically take advantage of this feature on supported hardware without you having to make any changes.
A new Snapshot feature in the maps API lets you capture a bitmap image of the current map in order to improve performance when an interactive map isn't necessary. We’ve also added a listener to the My Location button.

Google+, Photo Sphere, InstantBuy, and Analytics

If you’ve used Google+ sign-in you can take advantage of the new simplified sharing control that can be embedded directly within your app, simplifying the process of sharing content directly to Google+. We’ve also taken the opportunity to add some butter to the Google+ sign-in animation.
The Photo Sphere viewer has also been extended to include a compass mode that allows users to explore Photo Spheres by moving their phones.
The InstantBuy implementation has been improved to increase efficiency, with improved latency, a cleaner UI with contextual text and assets for the holo light theme, and support for passing through loyalty and offers information.

More About Google Play Services

To learn more about Google Play services and the APIs available to you through it, visit the Google Services area of the Android Developers site.

Friday, June 28, 2013

Google Cloud Messaging: Collapsible Messages

n a previous article, we looked at how to set up Google Cloud Messaging (GCM) in Android applications. We learned that GCM is a free service that allows us to push messages from the cloud to a number of mobile recipients running our Android application and registered with our service.
The push messages can be either collapsible or non-collapsible. “Collapsible” means that the most recent message overwrites any previous ones queued for sending. A typical example of collapsible messaging is a live game score. In case previous score updates haven’t reached their destination yet, the Android clients would only get the latest one. This happens however on a best effort basis: the order in which messages get sent in GCM is not guaranteed, so in some cases the “latest” message may not be actually the most recent one


Take a Baseball game between the Boston Red Sox and the New York Yankees as an example. Here’s how we would construct a collapsible update to send to devices registered with our sports push notification service. All code samples here are slight modifications of the GCM Demo application . As commented in the previous article, the reader is invited to download the Demo (both client and server) and experiment. The Demo uses theGCM helper library for Java that abstracts much of the low-level stuff (like handling messages in JSON format).
However, while being pretty useful for introducing GCM, the Demo doesn’t actually handle push content. It only fires & acknowledges the event, while the same notification (set up in the client’s configuration) is used in all cases (“From GCM: you got message!”). So let’s write some actual message sending & receiving code:
Server Code
1
2
3
4
5
6
7
8
9
10
11
12
13
// in imports
import com.google.android.gcm.server.Message;
 
// Inside send method, construct a collapsible message
Message message = new Message.Builder()
  .collapseKey("Fenway Park Game") // The key for all updates.
  .timeToLive(600) // Time in seconds to keep message queued if device offline.
  .delayWhileIdle(true) // Wait for device to become active before sending.
  .addData("team1", "Red Sox:1")
  .addData("team2", "Yankees:0")
  .build();
// send in chunks of 1,000 devices
//...
It’s worth noting that a given GCM message can be sent to up to 1,000 mobile clients at a time. In case our user base is larger than that, we’ll need to break the message sending process in chunks of 1,000 recipients. One way to do that would be to use a java.util.concurrent.Executor thread pool and send the chunks asynchronously, as does the GCM Demo server.
Client Code
Now we need to process the GCM message in our Android application:
1
2
3
4
5
6
7
8
9
10
11
12
// inside GCMIntentService
@Override
protected void onMessage(Context context, Intent intent) {
 
    String message = intent.getStringExtra("collapse_key")  + "\n"
                     + intent.getStringExtra("team1") + " "
                     + intent.getStringExtra("team2");
 
    displayMessage(context, message);
    // notify user
    generateNotification(context, message);
}
Notice how a collapse_key is set up by the server and retrieved by the client. That key is how GCM identifies the flow of collapsible updates for a given event. In case there are several push notifications queued for sending with the same collapse key “Fenway Park Game”, only the most recent one will be delivered.
Here’s how a the push notification above looks like on an actual Android device. The last screen is the opened GCMClient application turned into a “Sports Center” for demonstration purposes: