akexorcist / ScreenshotDetection

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

Can't detect in Chinese device like VIVO #2

Open shofiulla-iota opened 4 years ago

akexorcist commented 3 years ago

I don't have VIVO device to test this problem but I think it might be file path doesn't include "screenshot"

If you still have this problem. You can fork my repo and change the condition in ScreenshotDetectionDelegate.isScreenshotPath(path: String?)

But I still keep this open issue until I get some VIVO device.

pcholt commented 3 years ago

1

You might like to try retrieving the name of the final directory in DIRECTORY_SCREENSHOTS

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_SCREENSHOTS).name.toLowerCase(Locale.getDefault())

but I think that's only available in Android Q?

2

Perhaps if the detection of the screenshot directory path could be an optional parameter to the delegate class?

3

I can only see one place that MediaStore.Images.Media.EXTERNAL_CONTENT_URI is used in the android source code, and that is to signal that the user is taking a screenshot. Have you encountered anywhere that this URI is used that does not involve taking a screenshot? You might get away with not having a "screenshot" substring test at all.

akexorcist commented 3 years ago

@pcholt 1 and 2 I put that code in library for additional checking.

3 That's URI for general image content in Android. When we observe the changes in EXTERNAL_CONTENT_URI. It could be any image content. So we don't know which URI is coming from taking a screenshot.