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.

Okay, so you just installed XCode 6 in order to take advantage of Apple’s new programming language Swift. Then, when you create a new project and attempt to run it in the iOS simulator, it tells you it is unable to select the destination.

Here is what I did in so the list of iOS simulators will appear:

  1. In XCode, go to Preferences > Locations
    • Command Line Tools select Xcode 6.
  2. In the Terminal app, go to /Users/YOUR_USERNAME/Library/Developer/Xcode/DerivedData
    • delete everything
  3. Reboot your desktop/laptop


When you run XCode again and click on the iOS Device icon on the upper left side of the window, you should then be able to see the list of iOS simulators.

Related Posts Plugin for WordPress, Blogger...