Showing posts with label androiddev. Show all posts
Showing posts with label androiddev. Show all posts

Sunday, December 14, 2014

Migrating from LocationClient to FusedLocationProviderApi

Update: The documentation on developer.android.com has been updated.

The Google Play Services library on Android includes the Location APIs including the Fused Location Provider, Activity recognition and Geofencing APIs.

The goal of the Fused Location Provider from the documentation:
  • Simple APIs: Lets you specify high-level needs like "high accuracy" or "low power", instead of having to worry about location providers.
  • Immediately available: Gives your apps immediate access to the best, most recent location.
  • Power-efficiency: Minimizes your app's use of power. Based on all incoming location requests and available sensors, fused location provider chooses the most efficient way to meet those needs.
  • Versatility: Meets a wide range of needs, from foreground uses that need highly accurate location to background uses that need periodic location updates with negligible power impact.
The use of the location APIs is documented in a training tutorial called Making Your App Location Aware. Unfortunately, with recent updates of the Google Play Services library (version 6.5.+ at the moment) the tutorial is now outdated and doesn't work. The tutorials use the LocationClient class. The class was first deprecated then removed in version 6.5. When the class was deprecated, in the documentation, Google recommended to use the FusedLocationProviderApi instead.

LocationClient removed in version 6.5

Receiving Location Updates

The high level approach for receiving location updates is: 
  1. Request Location Permission
  2. Check for Google Play Services
  3. Define Location Services Callbacks
  4. Specify Update Parameters
  5. Start Location Updates
  6. Stop Location Updates
There are no differences between the LocationClient and FusedLocationProviderApi in steps 1, 2 and 4. The difference is in steps 3, 5 and 6.

Using the LocationClient

A striped down version of the code using the LocationClient looks like this:

Using the FusedLocationProviderApi

A striped down version of the code using the FusedLocationProviderApi looks like this:

Key differences

  1. ConnectionCallback interface from the GooglePlayServicesClient replaced with the ConnectionCallback interface from GoogleApiClient
  2. OnConnectionFailedListener interface from the GooglePlayServicesClient replaced with the OnConnectionFailedListener interface from GoogleApiClient
  3. Create a GoogleApiClient instead of LocationClient in onCreate
  4. In onStart and onStop use the GoogleApiClient instead of the LocationClient
  5. In onConnected use LocationServices.FusedLocationApi to request location updates
The switch from LocationServices to FusedLocationProviderApi shouldn't take more than a few minutes if you know what are you doing. Since Google are stubbornly refusing to document it I decided to write this blog post. I hope you find it useful.

Update: You can star this issue on the android bug tracker and maybe Google will fix the documentation. 

Tuesday, March 4, 2014

Star Falldown released

Almost a year ago, after creating a few apps for Android, I decided to make my fist game for Android. I didn't want to start from scratch so I decided to use a game engine. A friend of mine had experience with AndEngine and he recommended it.

I started experimenting with the engine and I liked how it worked. So I decided to make a game with it. I decided to make a Falldown clone. While I was making the game, the game evolved. I also took breaks to work on other projects.

A few days ago I launched a public beta, you can find out more about that here. About 20 people tested the game and I didn't find any serious problem. I want to thank everybody who tested the game.  I'm happy with how the game looks and I decided to publish it today.

Star Falldown
You can download the game form the Play Store.

I also want to thank my friend Paul G. Lux from Portugal who made the music and helped me with the promo video.

If you like the game don't forget to rate it and/or leave a review on the Play Store.

Friday, December 6, 2013

Color Mania Spree - Released

Color Mania Spree
Over the last 2-3 months me and +Кире Серафимов have been working on a Brain and Puzzle game for Android called Color Mania Spree.

You are presented with a black and white picture and a color palette. The goal of the game is to guess the missing colors from the image. There are 125 images in the game from different categories like logos from brands, country flags, games, cartoons etc. The images are grouped in 12 levels with 10-20 images each. There is a bonus level called Spree with all 125 images appearing in random order.
The game includes Leaderboards and Achievements powered by Play Game Services so you can compete with your friends.

Over the last 4 week the game was in beta while we tested the functionalists and implemented new ones. We want to thank all the beta testers who helped us improve the game.

On December 2 we finally published the game on the Google Play Store. In the meantime we released 4 new versions with improvements and small bug fixes.

The game is free with in-app purchase to remove the ads. You can also buy hints and rubies but you can enjoy the game without spending a single $.

For the first 1000 people who download the game we want to offer the in-app purchase for ads removal (worth $2) for free via promo code. All you have to do is download the game from the Play Store, click on Hints, click on Promo Code and enter the promo code CMSPREE. The ads will be removed the next time you start the app.

If you have any suggestions, comments for the game please leave a comment below.
Rating the game on Google Play would be really helpful.

Thursday, November 7, 2013

I'm making a game - Color Mania Spree

I'm working on a game for Android together with +Кире Серафимов.
The name of the game is Color Mania Spree.

You are presented with a black and white picture and a color palette. The goal of the game is to guess the missing colors from the image.

There are 125 images in the game from different categories like logos from brands, country flags, games, cartoons etc. The images are grouped in 12 levels with 10-20 images each. There is a bonus level called Spree with all 125 images appearing in random order.

Color Mania Spree
The game will use Google Play Services for achievements and leader-boards.

At the moment we are most of the game logic is done and the game is in beta. There are some bugs with the game-play, the tablet layout isn't finished, achievements and leader-boards are not yet implemented.

We are looking for beta testers to test the game trough Google Play.If you are interested drop me a message on Google+.