Comments (20)
i have same case and problem with you, but i follow step on https://github.com/rekab-app/background_locator/wiki/Use-other-plugins-in-callback and it's work, here is my Application.kt
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
import io.flutter.view.FlutterMain
import rekab.app.background_locator.LocatorService
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
LocatorService.setPluginRegistrant(this)
FlutterMain.startInitialization(this)
}
override fun registerWith(registry: PluginRegistry?) {
if (!registry!!.hasPlugin("io.flutter.plugins.sharedpreferences")) {
SharedPreferencesPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.sharedpreferences"))
}
}
}
and change the Manifestfile.
<application
android:name=".Application"
you need add shared pref plugin,change
import io.flutter.plugins.pathprovider.PathProviderPlugin
to this
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
and change
if (!registry!!.hasPlugin("io.flutter.plugins.pathprovider")) {
PathProviderPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.pathprovider"))
}
to this
if (!registry!!.hasPlugin("io.flutter.plugins.sharedpreferences")) {
SharedPreferencesPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.sharedpreferences"))
}
and in the static callback just use the shared pref plugin as usual
SharedPreferences prefs = await SharedPreferences.getInstance();
String somthing = prefs.getString('somthing');
from background_locator.
@wemersonrv I think I can do that this weekend.
from background_locator.
Thats strange it work on some devices but not even on the emulator, have you tried to run the example ? Starting at boot mean that we need a way to start the plugin directly from kotlin and not dart and I think it would require a lot of changes idk
And i do the same lol
from background_locator.
Can you show LocationService.kt
? Look like you didn't do the step 3 of Android. At the moment we can't use plugins on IOS by the way
from background_locator.
@RomanJos I followed all 3 steps.
I created Application.kt and configured in manifest.xml.
I am not familiar with native programming.
Why IOS is not working? there is steps for configure in IOS.
from background_locator.
@vimalmistry The Document and the code need to be updated, I will do it this weekend. Please be hold until then.
from background_locator.
@mehdok ohh :( Did you updated doc? I found some new informations in readme.md
One question. What is requirement of minimum android version? My client complaints it is not working on their older devices!
from background_locator.
Minimum android sdk is 16.
from background_locator.
Actually I modified the README 3 days ago so make sure to match changes on your project, it may resolve your issues 😉
I'm using it on a real Android 4.4.2 (API 19) and it work well I only have issue setting the accuracy to HIGH so I left it to NAVIGATION
from background_locator.
@RomanJos Sorry your changes in document isn't merged yet. If there is something that can help @vimalmistry please copy paste it here.
from background_locator.
No I mean the one that are already merged
I created Application.kt and configured in manifest.xml.
Its LocationService.kt on the readme
from background_locator.
Thanks for replies. I actually configured using old doc (Application.kt). It works very well in most devices Except some devices and also I can not run it on emulator. But in physical device it works. But I found service is terminated after reboot. Is there any quick fix to auto start on reboot.
I am not a native developer. So I don't know much about .kt and .java file. I am just copy pasting every time.😇
from background_locator.
@vimalmistry I'm not sure why you can not get it working on some device or simulator, But I can confirm that the plugin is working fine on simulator, both Android and iOS.
On Android I can add the RECEIVE_BOOT_COMPLETED
, it's not that hard to restart service when device rebooting, But it is something that only Android supports, as I know there is no similar feature on iOS, so for keeping everything equal I won't do it.
from background_locator.
Thanks for replies. I actually configured using old doc (Application.kt). It works very well in most devices Except some devices and also I can not run it on emulator. But in physical device it works. But I found service is terminated after reboot. Is there any quick fix to auto start on reboot.
I am not a native developer. So I don't know much about .kt and .java file. I am just copy pasting every time.😇
Hey, can you tell me how you managed to solve the issue? I'm getting the same problem with SharedPreferences package, while I'm trying to use it on the static callback function
from background_locator.
Have you followed the steps in the documentation?
https://github.com/rekab-app/background_locator/wiki/Use-other-plugins-in-callback
from background_locator.
@vimalmistry I'm not sure why you can not get it working on some device or simulator, But I can confirm that the plugin is working fine on simulator, both Android and iOS.
On Android I can add the
RECEIVE_BOOT_COMPLETED
, it's not that hard to restart service when device rebooting, But it is something that only Android supports, as I know there is no similar feature on iOS, so for keeping everything equal I won't do it.
@mehdok Any chance to convince you to make this implementation for Android?
Almost 90% here in Brazil are android devices: https://gs.statcounter.com/os-market-share/mobile/brazil
And worldwide is not so different: https://gs.statcounter.com/os-market-share/mobile/worldwide
from background_locator.
Below is the Java equivalent to the above if your project doesn't support Kotlin
<YOUR PACKAGE NAME HERE>
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import rekab.app.background_locator.LocatorService;
import io.flutter.plugins.firebase.cloudfunctions.CloudFunctionsPlugin;
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
LocatorService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
final String sharedPrefKey = "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin";
final String functionsKey = "io.flutter.plugins.firebase.cloudfunctions.CloudFunctionsPlugin";
if(!alreadyRegisteredWith(registry,sharedPrefKey))
{
SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
}
if(!alreadyRegisteredWith(registry,functionsKey))
{
CloudFunctionsPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebase.cloudfunctions.CloudFunctionsPlugin"));
}
}
private static boolean alreadyRegisteredWith(PluginRegistry registry, String key) {
if (registry.hasPlugin(key)) {
return true;
}else{
return false;
}
}
}
from background_locator.
@MazEbeid thanks! can you help with ios configuration?
from background_locator.
from background_locator.
@MazEbeid @ozz-rjq There is a bug with iOS that prevent the app to get a gps fix while app is terminated in iOS (or at least get a fix every 500 meter or so). Also there is a PR #59 which address this issue, but there is a bug with that too. It would be appreciated if anyone can help with that.
from background_locator.
Related Issues (20)
- 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
- Need Code or Library in kotlin only
- I so confused about "getting location updates even when the app is killed" !!!!
- Is it still maintained? HOT 1
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.