private void GetAddress()
{
#if UNITY_ANDROID
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject context = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaClass cls = new AndroidJavaClass("java.util.Locale");
AndroidJavaObject locale = cls.CallStatic<AndroidJavaObject>("getDefault");
AndroidJavaObject Address = new AndroidJavaObject("android.location.Address",locale);
AndroidJavaObject geoLocation = new AndroidJavaObject("android.location.Geocoder",context,locale);
object[] toastParams = new object[3];
toastParams[0] = 19.21426;
toastParams[1] = 72.8369;
toastParams[2] = 1;
List<AndroidJavaObject> AddList = geoLocation.Call<List<AndroidJavaObject>>("getFromLocation", toastParams );
string add = AddList[0].Call<string>("getCountryName");
Debug.Log(add);
#endif
}
Here the return type for getFromLocation is list of Address i’m not sure how to achieve this.
Geocoder class Here
I know this is achievable through geocoder api but that requires api key. so i’ve decided to go with this method but got stuck here.
Please help me with this issue.