Comments (5)
Ok i found the issue.
I'm using another library to get service status, and the two libraries conflicts.
Sorry for waste your time. This flutter package is very good
from background_locator.
Can you see the notification?
Can you check if the service is running in background or it is stopped?
from background_locator.
Yes, I see the notification and the debug console shows me the few operations done in background, but after this operations nothing was print in the console and nothing was sent ti my server side
from background_locator.
Are you testing example code? if not it would be nice if you share some code.
from background_locator.
`import 'package:background_locator/background_locator.dart';
import 'package:background_locator/location_dto.dart';
import 'package:background_locator/location_settings.dart'
as BackgroundLocationSettings;
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:location/location.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Tracking Prototype',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Tracking Prototype Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@OverRide
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
bool _trackingEnabled = false;
Timer timer;
bool _serviceEnabled;
PermissionStatus _permissionGranted;
Location location;
LocationData currentLocation;
static final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
String deviceId;
ReceivePort port = ReceivePort();
static final _isolateName = 'LocatorIsolate';
bool _first = true, _last = false;
@OverRide
void initState() {
super.initState();
if (IsolateNameServer.lookupPortByName(_isolateName) != null) {
IsolateNameServer.removePortNameMapping(_isolateName);
}
IsolateNameServer.registerPortWithName(port.sendPort, _isolateName);
port.listen(
(dynamic data) async {
await _sendMobileData(deviceId, data, null);
},
);
location = Location();
initializeLocation();
initPlatformState();
}
@OverRide
void dispose() {
IsolateNameServer.removePortNameMapping(_isolateName);
BackgroundLocator.unRegisterLocationUpdate();
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('This device has id: $deviceId'),
],
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: _trackingEnabled ? Colors.green : Colors.red,
onPressed: _enableDisableTracking,
tooltip: _trackingEnabled ? 'Disable Tracking' : 'Enable Tracking',
child: Icon(
Icons.power_settings_new,
color: Colors.white,
),
),
);
}
Future initializeLocation() async {
//check location permission and service enabled
}
Future initPlatformState() async {
await BackgroundLocator.initialize();
await BackgroundLocator.isRegisterLocationUpdate().then(
(bool isRunning) => debugPrint('Running ${isRunning.toString()}'));
}
void _enableDisableTracking() {
setState(() {
_trackingEnabled = !_trackingEnabled;
});
if (_trackingEnabled) {
BackgroundLocator.registerLocationUpdate(
callback,
androidNotificationCallback: notificationCallback,
settings: BackgroundLocationSettings.LocationSettings(
notificationTitle: "RemoteAngel Human",
notificationMsg: "We follow you!!!",
accuracy: BackgroundLocationSettings.LocationAccuracy.HIGH,
distanceFilter: 0,
interval: 1,
wakeLockTime: 20,
autoStop: false,
),
);
} else {
BackgroundLocator.unRegisterLocationUpdate();
debugPrint('Unregistered location update!!!');
_last = true;
Future.delayed(Duration(seconds: 1)).whenComplete(() => location
.getLocation()
.then((LocationData lastLocation) =>
_sendMobileData(deviceId, null, lastLocation)));
}
}
Future _sendMobileData(String deviceId, LocationDto currentLocationDto,
LocationData currentLocationData) async {
//there is the API call to send locations to server side
debugPrint(
'Sent =>
}
static void callback(LocationDto locationDto) async {
final SendPort send = IsolateNameServer.lookupPortByName(_isolateName);
send?.send(locationDto);
}
static void notificationCallback() {
debugPrint('notificationCallback');
}
}
`
This is my code. Thanks for attention
from background_locator.
Related Issues (20)
- error on launching example app HOT 3
- Restart service on device reboot is not working on android 12
- İOS : Data Null HOT 1
- How can I send data from location callback to controller? HOT 1
- location_callback_handler.dart not found when run release project HOT 5
- [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:untitled/location_callback_handler.dart' not found. HOT 4
- Unable to build flutter release version with background_locator lastest HOT 1
- Library Update
- Issue on release build HOT 8
- Unable to capture location in release mode (Android) HOT 4
- Unable to run on iOS
- Error java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient HOT 1
- Error on init app flutter with carp_background_location HOT 5
- java.lang.IncompatibleClassChangeError: The method 'com.google.android.gms.tasks.Task com.google.android.gms.location.FusedLocationProviderClient.requestLocationUpdates(com.google.android.gms.location.LocationRequest, com.google.android.gms.location.LocationCallback, android.os.Looper)' was expected to be of type virtual but instead was found to be of type interface (declaration of 'rekab.app.background_locator.provider.GoogleLocationProviderClient' appears in /data/app/com.doa.lojisoft.saray-JqLCd0a12SEpAYQu6cUZjg==/base.apk:classes2.dex) HOT 2
- Service stopped suddenly in release mode android
- Data type mismatch (nullable type) and method implementation error in kotlin code just after adding the dependency HOT 1
- [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument: is a regular instance: Instance of 'LocationDto'
- What is speed measured in?
- How to stop service after a period of time?
- Upgrade Background_Locator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from background_locator.