diff --git a/ohos/src/main/ets/MobileScannerPlugin.ets b/ohos/src/main/ets/MobileScannerPlugin.ets index b1240892427f585e83b01345fe05be5f105a1803..033f1e3778b02addb4804e93557d5f8011abffa6 100644 --- a/ohos/src/main/ets/MobileScannerPlugin.ets +++ b/ohos/src/main/ets/MobileScannerPlugin.ets @@ -24,7 +24,7 @@ import MethodChannel, { import MethodCall from '@ohos/flutter_ohos/src/main/ets/plugin/common/MethodCall'; import Log from '@ohos/flutter_ohos/src/main/ets/util/Log'; import { AbilityAware, AbilityPluginBinding, ByteBuffer } from '@ohos/flutter_ohos/index'; -import { UIAbility } from '@kit.AbilityKit'; +import { common } from '@kit.AbilityKit'; import { cameraPermission, checkPermissions, requestPermissions } from './CameraPermissions'; import { customScan, scanBarcode, scanCore, detectBarcode } from '@kit.ScanKit'; import EventChannel, { EventSink } from '@ohos/flutter_ohos/src/main/ets/plugin/common/EventChannel'; @@ -45,19 +45,19 @@ export class MobileScannerPlugin implements FlutterPlugin, MethodCallHandler, Ab onAttachedToAbility(binding: AbilityPluginBinding): void { Log.i(TAG, "onAttachedToAbility"); - this.ability = binding.getAbility() + this.context = binding.getAbilityContext() } onDetachedFromAbility(): void { Log.i(TAG, "onDetachedFromAbility"); - this.ability = null; + this.context = null; } private methodChannel: MethodChannel | null = null; private eventChannel: EventChannel | null = null; private eventSink: EventSink | null = null private applicationContext: Context | null = null; - private ability: UIAbility | null = null; + private context: common.UIAbilityContext | null = null; private textureId: number | null = null; private surfaceId: string | null = null; private binding: FlutterPluginBinding | null = null; @@ -119,7 +119,7 @@ export class MobileScannerPlugin implements FlutterPlugin, MethodCallHandler, Ab }); result.notImplemented() } else if (call.method === "request") { - requestPermissions(this.ability!.context, (err, msg) => { + requestPermissions(this.context, (err, msg) => { if (err) { result.success(false) } else {