Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get location on background #724

Open
codydev-git opened this issue May 18, 2022 · 2 comments
Open

get location on background #724

codydev-git opened this issue May 18, 2022 · 2 comments

Comments

@codydev-git
Copy link

My idea is
When App receives the background firebase notification, App gets the current location.

My code is

image

But I am getting an error.

E/MethodChannel#lyokone/location(27361): Failed to handle method call
E/MethodChannel#lyokone/location(27361): java.lang.NullPointerException: Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference
E/MethodChannel#lyokone/location(27361): at com.lyokone.location.MethodCallHandlerImpl.onGetLocation(MethodCallHandlerImpl.java:117)
E/MethodChannel#lyokone/location(27361): at com.lyokone.location.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:43)
E/MethodChannel#lyokone/location(27361): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/MethodChannel#lyokone/location(27361): at android.os.Handler.handleCallback(Handler.java:883)
E/MethodChannel#lyokone/location(27361): at android.os.Handler.dispatchMessage(Handler.java:100)
E/MethodChannel#lyokone/location(27361): at android.os.Looper.loop(Looper.java:237)
E/MethodChannel#lyokone/location(27361): at android.app.ActivityThread.main(ActivityThread.java:7971)
E/MethodChannel#lyokone/location(27361): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#lyokone/location(27361): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#lyokone/location(27361): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
I/flutter (27361): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (27361): PlatformException(error, Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference, null, java.lang.NullPointerException: Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference
I/flutter (27361): at com.lyokone.location.MethodCallHandlerImpl.onGetLocation(MethodCallHandlerImpl.java:117)
I/flutter (27361): at com.lyokone.location.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:43)
I/flutter (27361): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
I/flutter (27361): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
I/flutter (27361): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
I/flutter (27361): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
I/flutter (27361): at android.os.Handler.handleCallback(

Do you have an idea to fix this?
Thank you.

@tehsunnliu
Copy link

Getting the same error and location.onLocationChanged is not getting called

@anushaVinove
Copy link

Any solution for this issue yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants