akexorcist / ScreenshotDetection

[Android] Screenshot detection while user using your app
Apache License 2.0
160 stars 33 forks source link

There is fatal exception on ScreenshotDetectionDelegate line 142 #3

Closed crust87 closed 2 years ago

crust87 commented 3 years ago

https://github.com/akexorcist/ScreenshotDetection/blob/8d80751d77b73ab5b2cba34b73215038e01d6bf0/screenshotDetection/src/main/java/com/akexorcist/screenshotdetection/ScreenshotDetectionDelegate.kt#L142

this code makes android.database.CursorIndexOutOfBoundsException. I think it reports when no media file on device.

92tjdwhd commented 3 years ago

From what I've checked, it happens if you delete the photo after taking a screenshot.

moinahmed-probo commented 3 years ago

From what I've checked, it happens if you delete the photo after taking a screenshot.

Yes. I have also experienced the same issue. Did you find any fix?

Kurogoma4D commented 3 years ago

Same here. I think it caused by specified device. I tried to reproduce this on my Pixel 4a, but it works perfectly.

Kurogoma4D commented 3 years ago

I think it caused by specified device. I tried to reproduce this on my Pixel 4a, but it works perfectly.

I may have been wrong about this. I did a video capture instead of an image capture, then deleted it and it reproduced.

moinahmed-probo commented 2 years ago

Finally this issue is resolved ! Thanks a lot @Kurogoma4D When can we expect to have this feature in the release @akexorcist Thanks

akexorcist commented 2 years ago

@moinahmed-probo 1.0.2 will come in a few hours

rajatkumardhamija commented 2 years ago

Hi, @akexorcist this issue is still there in version 1.0.2

rajatkumardhamija commented 2 years ago

Fatal Exception: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:515) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:138) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:52) at android.database.CursorWrapper.getString(CursorWrapper.java:141) at com.akexorcist.screenshotdetection.ScreenshotDetectionDelegate.getFilePathFromContentResolver(ScreenshotDetectionDelegate.kt:142) at com.akexorcist.screenshotdetection.ScreenshotDetectionDelegate.onContentChanged(ScreenshotDetectionDelegate.kt:107) at com.akexorcist.screenshotdetection.ScreenshotDetectionDelegate.access$onContentChanged(ScreenshotDetectionDelegate.kt:32) at com.akexorcist.screenshotdetection.ScreenshotDetectionDelegate$startScreenshotDetection$1$invokeSuspend$$inlined$collect$1.emit(Collect.kt:134) at kotlinx.coroutines.flow.FlowKt__DelayKt$debounceInternal$1$3$1.invokeSuspend(Delay.kt:235) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:7684) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)