fluttercommunity / wakelock_plus

Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
BSD 3-Clause "New" or "Revised" License
71 stars 54 forks source link

Requires a foreground activity, #6

Open thefdisk opened 1 year ago

thefdisk commented 1 year ago

When I use this plugin and https://pub.dev/packages/presentation_displays and call showPresentation. The wakelock show log like this :

E/flutter ( 9659): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(NoActivityException, dev.fluttercommunity.plus.wakelock.NoActivityException: wakelock requires a foreground activity, Cause: null, Stacktrace: dev.fluttercommunity.plus.wakelock.NoActivityException: wakelock requires a foreground activity E/flutter ( 9659): at dev.fluttercommunity.plus.wakelock.Wakelock.toggle(Wakelock.kt:17) E/flutter ( 9659): at dev.fluttercommunity.plus.wakelock.WakelockPlusPlugin.toggle(WakelockPlusPlugin.kt:42) E/flutter ( 9659): at WakelockPlusApi$Companion.setUp$lambda$1$lambda$0(Messages.g.kt:143) E/flutter ( 9659): at WakelockPlusApi$Companion.$r8$lambda$V3Ef3eoUCWaUg6-SG5-vgDNZXN8(Unknown Source:0) E/flutter ( 9659): at WakelockPlusApi$Companion$$ExternalSyntheticLambda0.onMessage(Unknown Source:2) E/flutter ( 9659): at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:217) E/flutter ( 9659): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter ( 9659): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter ( 9659): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter ( 9659): at android.os.Handler.handleCallback(Handler.java:938) E/flutter ( 9659): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter ( 9659): at android.os.Looper.loop(Looper.java:223) E/flutter ( 9659): at android.app.ActivityThread.main(ActivityThread.java:7656) E/flutter ( 9659): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 9659): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/flutter ( 9659): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/flutter ( 9659): , null) E/flutter ( 9659): #0 WakelockPlusApi.toggle (package:wakelock_plus_platform_interface/messages.g.dart:105:7) E/flutter ( 9659): <asynchronous suspension> E/flutter ( 9659): #1 MethodChannelWakelockPlus.toggle (package:wakelock_plus_platform_interface/src/method_channel_wakelock_plus.dart:20:5) E/flutter ( 9659): <asynchronous suspension> E/flutter ( 9659):

flutter doctors :

Doctor summary (to see all details, run flutter doctor -v): [!] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-arm64, locale en-ID) ! Warning:dart` on your path resolves to /opt/homebrew/Cellar/dart/3.0.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dwi/Development/flutter. Consider adding /Users/dwi/Development/flutter/bin to the front of your path. [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] VS Code (version 1.81.1) [✓] Connected device (3 available) [✓] Network resources

! Doctor found issues in 1 category.`

hit-flutter commented 1 year ago

Any update on this?

sunjiaming commented 10 months ago

Follow up, I used this plugin to appear https://github.com/X-SLAYER/flutter_overlay_window