qiuxiang / flutter-android-window

A flutter plugin allows you to create native android floating window.
MIT License
63 stars 20 forks source link

在悬浮窗中使用audio_waveforms录音报错 #26

Open 2971026328 opened 1 year ago

2971026328 commented 1 year ago

你好大佬又来麻烦您了,我在您的项目android_window中使用audio_waveforms进行录音报错如下,我应该怎么解决 android_window: ^0.4.0 audio_waveforms: ^1.0.4

E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): Failed to handle method call E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): java.lang.NullPointerException E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at com.simform.audio_waveforms.AudioRecorder.isPermissionGranted(AudioRecorder.kt:141) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at com.simform.audio_waveforms.AudioRecorder.checkPermission(AudioRecorder.kt:146) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at com.simform.audio_waveforms.AudioWaveformsPlugin.onMethodCall(AudioWaveformsPlugin.kt:69) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at android.os.Handler.handleCallback(Handler.java:942) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at android.os.Looper.loopOnce(Looper.java:240) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at android.os.Looper.loop(Looper.java:351) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at android.app.ActivityThread.main(ActivityThread.java:8422) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584) E/MethodChannel#simform_audio_waveforms_plugin/methods( 5946): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) E/flutter ( 5946): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null, null, java.lang.NullPointerException E/flutter ( 5946): at com.simform.audio_waveforms.AudioRecorder.isPermissionGranted(AudioRecorder.kt:141) E/flutter ( 5946): at com.simform.audio_waveforms.AudioRecorder.checkPermission(AudioRecorder.kt:146) E/flutter ( 5946): at com.simform.audio_waveforms.AudioWaveformsPlugin.onMethodCall(AudioWaveformsPlugin.kt:69) E/flutter ( 5946): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter ( 5946): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter ( 5946): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter ( 5946): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter ( 5946): at android.os.Handler.handleCallback(Handler.java:942) E/flutter ( 5946): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter ( 5946): at android.os.Looper.loopOnce(Looper.java:240) E/flutter ( 5946): at android.os.Looper.loop(Looper.java:351) E/flutter ( 5946): at android.app.ActivityThread.main(ActivityThread.java:8422) E/flutter ( 5946): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 5946): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584) E/flutter ( 5946): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) E/flutter ( 5946): ) E/flutter ( 5946): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) E/flutter ( 5946): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18) E/flutter ( 5946): E/flutter ( 5946): #2 AudioWaveformsInterface.checkPermission (package:audio_waveforms/src/base/audio_waveforms_interface.dart:89:9) E/flutter ( 5946): E/flutter ( 5946): #3 RecorderController.checkPermission (package:audio_waveforms/src/controllers/recorder_controller.dart:253:20) E/flutter ( 5946): E/flutter ( 5946): #4 RecorderController.record (package:audio_waveforms/src/controllers/recorder_controller.dart:170:7) E/flutter ( 5946): E/flutter ( 5946):

2971026328 commented 1 year ago

已解决bug,悬浮窗内使用插件时无法获取到activity,把相关权限请求代码改了一下如果在悬浮的情况下不请求解决问题了