gdagitrep / native_screenshot_ext

Other
1 stars 4 forks source link

Enable for secondary entrypoint #2

Open sidetraxaudio opened 1 year ago

sidetraxaudio commented 1 year ago

Using a second entry point to create a floating widget;

@pragma("vm:entry-point")
void overlayMain() async {
// Create the floating action button that persists and takes a screenshot and communicates via isolates
}

Because it remains persistent over other apps, we would like it to be able to capture platform view when pressed while other apps are open but some sort of platform method channel failure happens - presumably because of the secondary entrypoint??

E/MethodChannel#native_screenshot_ext(22864): Failed to handle method call E/MethodChannel#native_screenshot_ext(22864): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.app.Activity.checkSelfPermission(java.lang.String)' on a null object reference E/MethodChannel#native_screenshot_ext(22864): at jpg.ivan.native_screenshot.NativeScreenshotPlugin.permissionToWrite(NativeScreenshotPlugin.java:395) E/MethodChannel#native_screenshot_ext(22864): at jpg.ivan.native_screenshot.NativeScreenshotPlugin.handleTakeScreenshot(NativeScreenshotPlugin.java:156) E/MethodChannel#native_screenshot_ext(22864): at jpg.ivan.native_screenshot.NativeScreenshotPlugin.onMethodCall(NativeScreenshotPlugin.java:138) E/MethodChannel#native_screenshot_ext(22864): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)

gdagitrep commented 1 year ago

Did you add

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

to your AndroidManifest.xml inside android/src/main/ directory?

sidetraxaudio commented 1 year ago

Yes mate for sure. It works fine in the main entrypoint main(). It just doesn't using a second entrypoint.