androidflutterandroid-wear-2.0

Flutter location stream not sending gps updates on Android Wear 2


I have a flutter app, that uses the location library, found here

I import with

import 'package:location/location.dart';

and later call with

location.onLocationChanged().listen((Map<String,double> currentLocation) {
  print("LocationListener " + currentLocation.toString());
}

This works fine when run on an avd phone emulator, and also on a real phone. I get periodic updates with new gps locations coming through.

However, I want to get this working on an Android Wear 2 device/watch.

If I try it in either an emulator or actual android watch (Huawei watch 2), the stream never seems to trigger. I'm also trying to update the location via the emulator, which again works with a phone, but doesn't work with a watch.

The adv device I'm trying is Android Wear Round API 26.

The actual device is

Wear OS By Google 1.6, Google Play Services 14.3.67, android o.s 8.0

Location is enabled on the phone. It's possible the avd watch location is expecting it from a phone, but the actual watch device isn't, as it can work standalone, and things like Google Maps work fine with it GPS wise.

Does Android Wear 2 treat GPS/listeners different in anyway that I should be aware of, and any way to get that working ?


Solution

  • I've got this working finally as I hadn't realised permissions requirements had changed, as per here.

    So I've added one of these...

    <!--<uses-permission android:name="android.hardware.location.gps" />-->
    <uses-permission android:name="android.hardware.location" />
    

    location permission seems to work, but you can add gps specifically if that is required.