-
-
Notifications
You must be signed in to change notification settings - Fork 869
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
Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Unable to detect current Android Activity., null) #334
Comments
PermissionHandler.PermissionManager, Unable to detect current Android Activity., null) |
if (await permission.isGranted) { |
Hi @CentForever |
any update?, i had the same issue |
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. |
Can we reopen this? Same issue when running D/permissions_handler(14367): Unable to detect current Activity. C:\Users\Nick\Documents\Projects\flutter_isolate>flutter doctor -v [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [√] Chrome - develop for the web [√] Android Studio (version 3.6) [√] VS Code (version 1.54.3) [√] Connected device (3 available) • No issues found! |
I have the same problem as @nmfisher |
Just spent a few hours digging through the plugin to see how this can be fixed. Background - I want to request microphone permissions from some code that's running in a secondary FlutterEngine that is created in a background isolate. On Android, this FlutterEngine is created without an associated Activity, which is causing the error message "Unable to detect current Android Activity". As far as I can see, Android has no way of requesting permissions without an Activity. As a workaround, you need to launch a temporary/invisible Activity that handles the permission request, then kills itself when done. I've created a proof-of-concept here but this definitely isn't production-ready (for example, concurrent/asynchronous requests (without await) on the Dart side won't complete properly. The reason I'm not going to finish it off is because it's trivial enough for me to just request permissions in the foreground. I figured I'd push to GitHub in case anyone wants to take it further. |
I also need to check permission in background. How did you get the workaround and please provide a link for that or just example of code here. |
Is there any update on this? |
low level coded beauty ? |
So we can't ask permission from background with this package? |
The 'active' issue is here : #269 |
same issue |
When flutter page A is embedded in Android Fragmnet B with io.flutter.embedding.android.FlutterView, this error occurs when A executes await Permission.microphone.request(); |
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Unable to detect current Android Activity., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#3 MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:66:30)
#4 PermissionListActions.request (package:permission_handler/permission_handler.dart:105:16)
#5 PermissionUtil.deal (package:fluttermodule/common/utils/permission_util.dart:13:23)
#6 _DemoImagePictureState.loadAssets (package:fluttermodule/page/demo_image_picture.dart:67:43)
#7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#8 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:862:36)
#9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
#12 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
#13 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
#14 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
#15 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9)
#16 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#17 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
#18 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
#19 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
#20 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#21 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#22 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#23 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#24 _rootRunUnary (dart:async/zone.dart:1196:13)
#25 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#26 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#27 _invoke1 (dart:ui/hooks.dart:275:10)
#28 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
The text was updated successfully, but these errors were encountered: