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

Headless Background Task can not be executed #12

Closed
plake876 opened this issue Feb 25, 2019 · 1 comment
Closed

Headless Background Task can not be executed #12

plake876 opened this issue Feb 25, 2019 · 1 comment

Comments

@plake876
Copy link

Hi,
if the barcode scan library (barcode_scan: ^0.0.8) is used,
the following exception occurs after the background task is triggered (adb shell cmd jobscheduler run -f 999)

java.lang.RuntimeException: java.lang.IllegalStateException: registrar.activity() must not be null
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:112)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:108)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.os.Looper.loop(Looper.java:166)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7425)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: Caused by: java.lang.IllegalStateException: registrar.activity() must not be null
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.apptreesoftware.barcodescan.BarcodeScanPlugin$Companion.registerWith(BarcodeScanPlugin.kt:19)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.apptreesoftware.barcodescan.BarcodeScanPlugin.registerWith(Unknown Source:2)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:22)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.example.xyz.Application.registerWith(Application.java:17)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.initFlutterView(HeadlessTask.java:133)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.(HeadlessTask.java:47)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.HeadlessJobService.onStartJob(HeadlessJobService.java:38)
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.app.job.JobService$1.onStartJob(JobService.j
02-25 11:32:42.472 11461 11461 E AndroidRuntime: at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java)

The Task will not be excecuted.
Thanks for your help.

@christocracy
Copy link
Member

This is basically a duplicate of #11.

All plugin developers need to guard themselves against the case where an App can launch Headless, where registrar.activity() == null.

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

2 participants