I am working on an app that have registration process and my requirements are:
Requirements:
- Automatically select country code with the help of device IP address tracing.
- Detect user location during registration and save it.
I searched a bit but did not find any useful information that would lead to an answer, there must be way but what is that? Please let me guide to the way
If you address from user as an input during registration, you can find geo coordinates from address. Fore more information see https://developers.google.com/maps/documentation/geocoding/#Geocoding
Regarding country code from IP address, you can also utilize an online service like
http://www.whois.net/ip-address-lookup/ and parse the response to retrieve the country code. Here is how you can parse it (the code is in PHP but you can easily modify it)
Get user location:
String locationProvider = LocationManager.NETWORK_PROVIDER;
// Or use LocationManager.GPS_PROVIDER
Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
http://developer.android.com/guide/topics/location/strategies.html
Use GeoCoder to get the Address (with country)
GeoCoder.getFromLocation()
http://developer.android.com/reference/android/location/Geocoder.html