Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-603

Phonegap didn't trigger GPS

    XMLWordPrintableJSON

Details

    Description

      I'm trying to get my position with GPS.

      I just implement the "Full Example" from here: http://docs.phonegap.com/en/1.6.1/cordova_geolocation_geolocation.md.html#Geolocation

      I tested with 1.6.0, 1.6.1 and 1.7.0rc1.

      The problem: app didn't trigger the GPS to get my current position. Even when I check "Data enable".

      Here is my code:
      <!DOCTYPE html>
      <html>
      <head>
      <title>Device Properties Example</title>

      <script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
      <script type="text/javascript" charset="utf-8">

      // Wait for Cordova to load
      //
      document.addEventListener("deviceready", onDeviceReady, false);

      // Cordova is ready
      //
      function onDeviceReady()

      { navigator.geolocation.getCurrentPosition(onSuccess, onError); }

      // onSuccess Geolocation
      //
      function onSuccess(position)

      { var element = document.getElementById('geolocation'); element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + 'Longitude: ' + position.coords.longitude + '<br />' + 'Altitude: ' + position.coords.altitude + '<br />' + 'Accuracy: ' + position.coords.accuracy + '<br />' + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' + 'Heading: ' + position.coords.heading + '<br />' + 'Speed: ' + position.coords.speed + '<br />' + 'Timestamp: ' + new Date(position.timestamp) + '<br />'; }

      // onError Callback receives a PositionError object
      //
      function onError(error)

      { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); }

      </script>
      </head>
      <body>
      <p id="geolocation">Finding geolocation...</p>
      </body>
      </html>

      And the XML file:
      <?xml version="1.0" encoding="utf-8"?>
      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.phonegap.helloworld"
      android:versionCode="1"
      android:versionName="1.0" >
      <supports-screens
      android:largeScreens="true"
      android:normalScreens="true"
      android:smallScreens="true"
      android:resizeable="true"
      android:anyDensity="true"
      />
      <uses-permission android:name="android.permission.CAMERA" />
      <uses-permission android:name="android.permission.VIBRATE" />
      <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_LOCATION_EXTRA_COMMANDS" />
      <uses-permission android:name="android.permission.READ_PHONE_STATE" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.RECEIVE_SMS" />
      <uses-permission android:name="android.permission.RECORD_AUDIO" />
      <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
      <uses-permission android:name="android.permission.READ_CONTACTS" />
      <uses-permission android:name="android.permission.WRITE_CONTACTS" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.GET_ACCOUNTS" />
      <uses-permission android:name="android.permission.BROADCAST_STICKY" />

      <uses-sdk android:minSdkVersion="7" />

      <application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" >
      <activity
      android:name=".App"
      android:label="@string/app_name"
      android:configChanges="orientation|keyboardHidden">
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />

      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      </activity>
      <activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden"> <intent-filter> </intent-filter> </activity>
      </application>
      </manifest>

      Attachments

        Activity

          People

            bowserj Joey Robert Bowser
            beier Lucas Falk Beier
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: