Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android can't retrieve my current position (Appcelerator Titanium)

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!

like image 478
Zakaria Avatar asked Nov 06 '22 04:11

Zakaria


1 Answers

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

like image 55
Sherif elKhatib Avatar answered Nov 09 '22 03:11

Sherif elKhatib