I'm using Titanium SDK 1.5.1 for both iPhone and Android development. I have an app that loads a map with my current position perfectly on iPhone. But, for android, nothing is showing but an error from the Geolocation API.
I added my Android Map API key and other properties in the tiapp.xml file:
<property name="ti.android.debug" type="bool">false</property>
<property name="ti.android.google.map.api.key.development">xxxxxxxxxxxxxxxxxxx</property>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
</android>
Then, in my js file, I added the two lines:
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
And, for the call, here is the code:
Titanium.Geolocation.getCurrentPosition(function(e){
if (e.error)
{
alert('Error while retrieving your position!');
return;
}
var longitude = e.coords.longitude;
var latitude = e.coords.latitude;
....
On my device, the app returns the alert above even if I allow Android to access to my position (in Android Settings).
So what is the problem?
Thanks by advance!
Quoting @Fa11enAngel J
This one seems to be a bug in Titanium 1.5.1.
I've seen support requests regarding this topic.
Try to use the nightly builds: Appcelerator Continuous Builds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With