User Cristian in the StackOverflow forum provided some code on how to get the country name based on the Location’s latitude and longitude coordinates.

While this may work at first, you might find out while testing that on the 2nd try, the GeoLocation objects produces a NullPointerException.

This is actually because the Google Maps API has a limit on free requests. If you wish to make sure your app never crashes when it checks for the country name, you will have to pay.

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.

Vehicle Theft means headache and heartache for most people and major upheaval for businesses. Yet what are you doing to prevent it?

In the US a car is reported as stolen every 26 seconds and if you are lucky enough to live or work anywhere near a port or border city, the likelihood of having your vehicle stolen increases dramatically, with thieves using this geographical advantage to ship and export cars in return for payment way above the vehicle’s market value.

One very successful way to combat this crime is to have a GPS tracking device fitted. The device is no bigger than a mobile phone and can be easily hidden in any type of vehicle; from luxury motors to the humble van – even trailers can be protected.

How does it Work?

GPS (Global Positioning System) is a network of 24 satellites and numerous ground stations which are used in conjunction with GPS trackers and receivers to work out exactly where something is at any given time, using ‘triangulation’.

The GPS tracking system can be remotely accessed and allows you to pinpoint a vehicle’s exact location in real-time. It will even record the position of the vehicle at regular intervals, which almost guarantees its recovery in the unfortunate event of it going walkabouts!

There is additional great news if you are a fleet owner wanting to track the movements of your employees on day-to-day basis as you can use the system to check productivity, work out how long a particular route takes and even how many rest stops they take!

Food for thought

In April 2012 a car rental company in Los Angeles for GPS tracking to recover a Ferrari 458 Italia that had been rented out for a daily rate of $2,000. The rental owner grew suspicious when the tracking system showed no movement from the vehicle for several days and alerted the authorities, who tracked the vehicle to Hong Kong where is had been shipped by a member of a notorious car crime syndicate.

Related Posts Plugin for WordPress, Blogger...