Merge pull request #123 from mjafartp/master

App Crash with Background fetch plugin cleared
This commit is contained in:
Matthew Smith 2019-06-11 07:36:18 -07:00 committed by GitHub
commit 18960bd493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,9 +16,11 @@ class BarcodeScanPlugin(val activity: Activity): MethodCallHandler,
@JvmStatic @JvmStatic
fun registerWith(registrar: Registrar): Unit { fun registerWith(registrar: Registrar): Unit {
val channel = MethodChannel(registrar.messenger(), "com.apptreesoftware.barcode_scan") val channel = MethodChannel(registrar.messenger(), "com.apptreesoftware.barcode_scan")
val plugin = BarcodeScanPlugin(registrar.activity()) if (registrar.activity() != null) {
channel.setMethodCallHandler(plugin) val plugin = BarcodeScanPlugin(registrar.activity())
registrar.addActivityResultListener(plugin) channel.setMethodCallHandler(plugin)
registrar.addActivityResultListener(plugin)
}
} }
} }