rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

Does someone also face crash issue when running on Android OS 8? #211

Open function2000 opened 3 years ago

function2000 commented 3 years ago

Does someone also face crash issue when running on Android OS 8? I get crash when run on Android OS 8.

mehdok commented 3 years ago

Hi @function2000 Thank you for opening an issue;

What kind of issue do you have with Android 8?

function2000 commented 3 years ago

Hi @function2000 Thank you for opening an issue;

What kind of issue do you have with Android 8?

When asked for permission, click allow, then it crashed,and then app cannot be open again. That is the reason I asked if somebody else face the same issue.

function2000 commented 3 years ago

Hi @function2000 Thank you for opening an issue;

What kind of issue do you have with Android 8?

Please see below screenshot, maybe you can also have a try on Android 8 device: erro1

error2

function2000 commented 3 years ago

@mehdok any solution to make it work on Android 8? Thanks!

mehdok commented 3 years ago

@function2000 Please show me some code;

function2000 commented 3 years ago

@function2000 Please show me some code;

Sorry for late reply, here below are some code. I don't think it is my code issue, perhaps you try run on Android 8, you will see the same problem.

================================> void _startLocator() { Map<String, dynamic> data = {'countInit': 1}; BackgroundLocator.registerLocationUpdate(LocationCallbackHandler.callback, initCallback: LocationCallbackHandler.initCallback, initDataCallback: data, / Comment initDataCallback, so service not set init variable, variable stay with value of last run after unRegisterLocationUpdate / disposeCallback: LocationCallbackHandler.disposeCallback, iosSettings: IOSSettings( accuracy: LocationAccuracy.NAVIGATION, distanceFilter: 0), autoStop: false, androidSettings: AndroidSettings( accuracy: LocationAccuracy.BALANCED, interval: 60, //1 minute wakeLockTime:1440, //24hours distanceFilter: 0, client: LocationClient.android, androidNotificationSettings: AndroidNotificationSettings( notificationChannelName: 'nxxii_gps_bg', notificationTitle: 'Running in background', notificationMsg: 'Updating...', notificationBigMsg: 'Updating...', notificationIcon: '', notificationIconColor: Colors.grey, notificationTapCallback: LocationCallbackHandler.notificationCallback) )); }

................

void _onStart() async { if (await _checkLocationPermission()) { _startLocator(); final _isRunning = await BackgroundLocator.isServiceRunning();

  setState(() {
    isRunning = _isRunning;
    lastTimeLocation = null;
    lastLocation = null;
  });
} else {
  // show error
}

}

............................................. void initGeoLocator(){

if (IsolateNameServer.lookupPortByName(
    _isolateName) !=
    null) {
  IsolateNameServer.removePortNameMapping(
      _isolateName);
}

IsolateNameServer.registerPortWithName(
    port.sendPort, _isolateName);

port.listen(
      (dynamic data) async {

          lastLocation = data;
          positions.add(data);
      },
);
initGeoPlatformState();
_onStart();

}

zy693415 commented 2 years ago

android 8.1

@function2000 请给我看一些代码;

android 8.1 I have the same problem,Brand is the oppo