How to get 2 Character Country name using longitude and longitude android? - android

I can get the longitude and longitude android. And now I want to get the short country name against it. How to do that? I also have country code... All I want is to show short country name e.g "UK" , "SG" etc...

Finally I found a web-service that give 2 digit country code along with temperature.
Its very simple
http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=31.50766766,74.33741188000002

Related

Populate a ListView with GeoPoints near me

I have a table at Parse.com full of addresses of places.
Every row contains the name of the address, and a GeoPoint (Latitude and Longitude).
I want to do 2 things:
1. Populate a ListView with data from my table (name and address), but places that are not further than, for example, 500 meters;
2. Convert the GeoPoint to an address (Street, City), so every ListView item will be shown like this:
Address Name
Street (with number of the house), City.
Can you please help me?
I found an answer for my first question. I've added that code in the activity AsyncTask on the doInBackground method.
Use this guide, together with
query.whereWithinKilometers("Location", geoPoint, 1.5);

How to find all the addresses using postal code in android ?

When I entered a postal code in my Edittext and click on a button, I need to show a address list related to that particular postal code in a Spinner.
You need to use Geocoder class for your requirement. The thing you are asking in known as reverse-geocoding.
There is service provided by google.
http://maps.google.com/maps/api/geocode/json?address=&components=postal_code:15204&sensor=false
In the URl 15204 is the postal code. Make a call to the url with the postal code in place.
This returns a json format, parse the list of cities with the postal code.
Probably first result is what you are looking for.

How to check if address is contained in a continent or close to another address in android google maps api v2?

In my app, I have a list of locations, and I want to create filter settings. I am looking for a way so that a user can pick maybe a continent or country or address and then filter out the locations from the list if the location is within the continent or country or close to the address.
Is there a google maps v2 api for android that can do something like:
public Boolean AddressIsContained(String address, String place);
which returns true if address is within place (place could be like a country or continent). And also like
public Boolean AddressCloseTo(String address1, String address2, int distance);
which returns true if address1is within distance amount of kilometers to address2. And this would just be a straight line between the addresses, nothing like a bike, walk, car or plane route.
Also for the list of locations, I am also able to access its lat/long if that makes it easier.
Thanks
For the start I assume you are familiar with the GeoCoder and / or GeoCoding API to get the addresses for your locations.
If you use the GeoCoder you will get a List of Address objects. The Address class provides some methodes to get the country or city name f.e. These methods you can use for your filter.
The Location class includes the methods distanceBetween() and distanceTo(). These you can use to check the distance between your locations.

How to point to country by it's name?

Assuming that I don't know my current location, how to move MapView to country by it's name?
What I'm trying to do is display user's country by country code in locale.
There isn't such a table in android with a link between country and geolocation that I'am aware of.
I believe the best approach is to get a list of all capital cities with latitude and longitude (you can get them here : list of capital cities) or a list of countries (you can get them from here : list of countries) and put it in a table in your application.
good luck.
Yes you can display User's country by Country Code.
As we have facility to get the CountryCode through Android Telephony Manager Api so.
1)You have to use Key Value pairs concept, Key as CountryCode and Value as Country.
like the following code:
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
manager.getNetworkCountryIso();

How to get the nearest city from google place api (android) based on a given latitude and longitude

I am getting a latitude and longitude from GPS and want to search the nearest city from my current location.
Currently I'm sending a request to Google Places with types like "neighborhood|locality", but this does not return any nearest city. Even if I only specify "neighborhood" or "locality" by themselves, I still get no results. However if I use a type like "bar" then it returns a list of bars.
I'm using the types listed here:
https://developers.google.com/places/documentation/supported_types
Can anybody tell me what Place Type I should use to get the nearest city or places, or how I can otherwise get the nearest city?
Are you getting back a results array with nothing in it, or simply getting nothing back? The docs say you'll get a results array "even if the service returns no results". Is it possible that the city you're searching contains bars but does not contain anything classified as a "neighborhood" or a "locality"?
This question says
you can restrict the results that will come back in the Autocomplete
to addresses by setting types to 'geocode' ... you can restrict the
results that come back in the Autocomplete to cities by setting types
to 'cities'
If you're just trying to get the city name, rather than searching for something inside the city, perhaps you want to use one of those options?

Categories

Resources