Comments (7)
I will try to update the code to use the Context directly available from registrar to avoid to pass by the Activity.
from flutter-geolocator.
@sestegra I checked our code and the error happens on the spot where the native code returns the result to Dart using the instance of the MethodResult
class. Looking into the "android_alarm_manager", it looks like the printHello
method is called from the background. Did you follow the instructions on the documentation of the "android_alarm_manager" explaining the usage of other Flutter plug-ins together with the "android_alarm_manager" (to following is copied directly from the README):
If alarm callbacks will need access to other Flutter plugins, including the alarm manager plugin itself, it is necessary to teach the background service how to initialize plugins. This is done by giving the AlarmService a callback to call in the application's onCreate method. See the example's Application overrides. In particular, its Application class is as follows:
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
AlarmService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
}
from flutter-geolocator.
@mvanbeusekom I not only follow the documentation, I updated the example (that implements the Application class) to call Geolocator.
Basically, I cloned the plugins project, update the example code with above snippet and run it.
from flutter-geolocator.
I still got the following error coming from permissions.
D/permissions_handler( 9153): Unable to detect current Activity.
from flutter-geolocator.
It works if I get permission from MainActivity.
from flutter-geolocator.
@sestegra the problem with the permissions can also be solved by taking care of them manually when the App starts using the permission_handler plugin.
Unfortunately to take care of permissions we do need an Activity
(which makes sense because we need to show the user a dialog). So by taking care of the permissions manually when we are sure the App is running (before we launch services in the background) we can be sure there is an activity.
Then when the Geolocator
gets called it will notice that all permissions are taken care of and will simply continue acquiring the location and not try to get the required permissions.
from flutter-geolocator.
@sestegra a quick follow up, we just release version 1.6.3 of the Geolocator plug-in which includes your changes. Thanks again for reporting the issue.
from flutter-geolocator.
Related Issues (20)
- [Bug]: NoSuchMethodError (NoSuchMethodError: The method 'toInt' was called on null. Receiver: null Tried calling: toInt()) HOT 3
- [Bug]: Missing permissions required by NotificationManagerCompat.notify HOT 5
- [Regression]: on version 10.1.0 with android getCurrentPosition takes at least 30 seconds to load. I tried ^8.2.0 and it takes only 0.02s HOT 12
- [Bug]: The app is still running in background event if it's killed HOT 10
- [Bug]: `checkPermission()` does not reflect correct state after granting permissions via `requestPermission()` in Safari.
- [Bug]: Tapping outside Android location permission dialog results in `LocationPermission.deniedForever` HOT 4
- [Question]: [Bug]: Fetching user's coordinates working fine in debug mode but we launch app in release mode or built release apk the coordinates of the user's not fetched HOT 2
- [Question]: offline mode HOT 1
- [Bug]: getPositionStream causes exception when run on device without GMS (using default location manager) HOT 5
- [Bug]: Apple complains about the need for NSLocationAlwaysAndWhenInUseUsageDescription HOT 9
- [Regression]: There is crash when running building command. HOT 2
- [Bug]: No error when starting the app with location turned off. HOT 3
- [Question]: Position from getPositionStream() has 0 altitude HOT 5
- [Bug]: Android 13 getPositionStream fail HOT 3
- [Bug]: altitude property still 0 HOT 4
- [Bug]: Not able to get User location sometimes HOT 2
- [Bug]: LocationServices.getPosition, kCLErrorDomain error 1 HOT 9
- [Bug]: Unable to run on Windows : Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.220418.1 HOT 1
- [Enhancement proposal]: throw UnsupportedError instead of UnimplementedError. HOT 1
- How can i dissable log write in my flutter app using this pluggin? HOT 2
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 flutter-geolocator.