When I searched in Google on how to get the current location in Android, I came across  the page in Android’s documentation about connecting to Google Play Services and initializing it.

I found out this was really not needed. If I could get the location without having to use this, all the better right?

User MrJre from the StackOverflow forum provided this very handy, useful, clean and non-Google Play Services type of code.

All you need are some broadcasters, receivers and listeners. This is how I did using some of his code. The code will try to get locations through GPS or WI-FI in case one or the other fails.

First off, place this code in a class.

Then create a broadcast class that will fire events to all listeners when a location has been found.

Next, create a listener for use in any Activity that may use location tracking.

All classes are now in place. The next thing to do is to implement the listener to your Activity.

In the onCreate() method, the fetchLocation() method is called and once a location is found, the broadcaster will fire the gotLocation() method to all listeners and return a Location object.

That’s it! And without having to use Google Play Services to get a location object.

This is a Sponsored Post written by me on behalf of Dual Electronics. All opinions are 100% mine.

Say hello to another device offering the latest technology:  the XDMA6630 by Dual Electronics.  It is a mobile receiver with Bluetooth capabilities that allows you to sync your mobile phone for hands-free calling while also providing support for streaming stereo audio as well as a direct USB connection for iPods and iPhones enabling direct music playback through any USB flash storage devices.

The Dual XDMA6630 single din has a detachable face which is easy to read and use, featuring sleek and subtle contours accentuated by a black and white LCD. A wireless remote control is included with this device, enabling any user to control tunes from a distance. A very neat feature that I am impressed with is its accessibility of a steering wheel control interface when plugged in with the PAC-SWI-PS adapter (sold separately).

I also think its CD-R and RW discs compatibility that allows for even more music to play is an added bonus feature. With all the convenient features that the XDMA6630 mobile receiver has, any owner will enjoy and experience enhanced lifestyle with music enjoyment and communication. Increase your cool factor by getting an XDMA6630 yourself for the ultimate car audio experience!

Check out the site to see more details regarding the XDMA6630.
Visit my sponsor: Dual Electronics new car audio receiver...

Related Posts Plugin for WordPress, Blogger...