Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-4982

Geolocation not working consistently on Android WebView (with suggested patch)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 2.0.2
    • Component/s: Android
    • Environment:

      Description

      My experience shows that geolocation doesn't work consistently in an Android WebView, even when android.permission.ACCESS_FINE_LOCATION is added to tiapp.xml.

      To replicate:

      • Create simple app that loads a web page that uses geolocation APIs. In this case I used the KitchenSink app and changed the external URL in web_views.js to a test page for W3C browser geolocation, http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html.
      • Add to tiapp.xml:
        • <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

      • Save and build as usual. Install to Android device and to iOS device for comparison.
      • Verify that the permission privilege was added to build/android/AndroidManifest.xml.
      • Open KitchenSink on Android device and go to Base UI > Views > Web Views > External URL. Geolocation test fails.
      • Open KitchenSink in iOS device and repeat process. App requests location permission and test completes.

      Here is my suggested resolution to the problem:

      • Add the following to source code for TiWebChromeClient.java:
        • public void onGeolocationPermissionsShowPrompt(String origin, android.webkit.GeolocationPermissions.Callback callback) {
               callback.invoke(origin, true, false);
          }

      • Build and update titanium-ui.jar.
      • Clean and build project and install new build to Android device.
      • Open KitchenSink on Android device and go to Base UI > Views > Web Views > External URL. Geolocation test succeeds!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                krowley Karl Rowley
                Reporter:
                allankim Allan Kim
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-4218
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code