Vaadin TouchKit geolocation on Android

Hello,

I’ve run into a bit of a problem whilst developing an app using Vaadin TouchKit. The app is heavily location based, and one of key functionalities is detecting your current position from the device and then proceeding. I’ve implemented this as follows:

public class LocationSelectMethodView extends NavigationView implements PositionCallback {

// snip code

  // A button is pressed

   applicationWindow.detectCurrentPosition(this); // ApplicationWindow inherits TouchKitWindow


  public void onSuccess(Position position) {

      Point location = new Point(position.getLongitude(), position.getLatitude());

      // do something fancy with the location
  }


  public void onFailure(int i) {

      // show popover with failure code 
  }   

// snip code

This works like a charm on an Ipad, N9, Symbian device and the supported desktop browsers. These platforms behave as expected, they first ask the user for geolocation permission and then successfully achieve the correct location. If permission is denied, the popover is shown.

Android 4.0.4 on a Samsung Galaxy S3 presents the problem that I’m facing: this doesn’t work either with the default browser nor Chrome. On Chrome it at least asks for the permission, but neither one of the methods (onSuccess, onFailure) gets triggered. The default browser doesn’t even get around to asking a permission.

I’ve tried disabling GPS (so the device would figure out the location based on the mobile network), but the behaviour is still similar.

Anyone have geolocation working with any Android devices? This could be a problem with either Android not supporting the mechanism TK uses, or my device settings are incorrect. I’ve tested with the Maps-app that the device can detect its position, though. Any fixes and suggestions are very welcome.

Cheers,

Teme

Hi,

I don’t have that exact Android device on my hands, but I can verify geolocation has worked with all Android devices I have tested. Maybe you should see you devices settings that you have not blocked the access permanently for your app.

For me the only browser that has caused issues with geolocation is the one on iOS 6 and there especially when web app is saved as “home screen web app”. Those will be fixed in iOS 6.1.

cheers,
matti

Hi Matti,

thanks for the confirmation that it should work also on Android. I don’t have any other devices to test with so that is pretty much all I need to know for now. I’ll check the device settings again in case I overlooked something the first three times :slight_smile:

-Teme

For anyone running into this issue, it seems that upgrading Android to version 4.1.1 fixed it. Pre-upgrade (4.0.4) I was able to use the HTML5 geolocation successfully with Firefox, but not with the default browser or Chrome, so it was not about the device settings. After upgrading, the geolocation in my Touchkit app works flawlessly.

Ok, good to hear it works now. One of our test devices has 4.0.3, so I guess I better not upgrade it - at least to 4.0.4.

Maybe this is some kind of joke from the Android theme. 404 - not found :grin:

cheers,
matti