Skip to content
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

Not able to detect Screenshot on Android 13. #66

Closed
psbdgr8 opened this issue Jun 2, 2023 · 9 comments
Closed

Not able to detect Screenshot on Android 13. #66

psbdgr8 opened this issue Jun 2, 2023 · 9 comments

Comments

@psbdgr8
Copy link

psbdgr8 commented Jun 2, 2023

It is working with android 12 and below and iOS 16.5 as well.
but not able to detect on Android 13+, any help will be appreciated

@Sun-Woo-Kim
Copy link

same issue

@psbdgr8
Copy link
Author

psbdgr8 commented Jun 13, 2023

@Sun-Woo-Kim if you find any workaround or another Module, please share Thanks.

@elmotan95
Copy link

I think this is may relate to permission
https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

This library rely on Manifest.permission.READ_EXTERNAL_STORAGE which is not relevant anymore on Android 13

@elmotan95
Copy link

I already solve the problem.

Make sure to ask permissions with react-native-permissions and for Android 13 or later, check permission for READ_MEDIA_IMAGES, other than that you can use READ_EXTERNAL_STORAGE.

You can test screenshot with emulator by using this command
adb shell /system/bin/screencap -p /sdcard/screenshot.png

I made some adjustment too on native module, you can check the PR here
#67

For quick fix you can do patch-package

@psbdgr8
Copy link
Author

psbdgr8 commented Jun 26, 2023

@elmotan95 Thank you so much it resolved my issue.
To resolve the problem of the screenshot detection occurring twice and encountering the "lateinit contentObserver has not been initialized" error, I had to perform slight adjustments to the code. You can refer to the changes made in fork #68 for further details.

@psbdgr8 psbdgr8 closed this as completed Jun 26, 2023
@elmotan95
Copy link

Thanks!
Yeah I got that error too randomly (don't know how to reproduce) after checking your comment.

@psbdgr8
Copy link
Author

psbdgr8 commented Jun 26, 2023

Thanks! Yeah I got that error too randomly (don't know how to reproduce) after checking your comment.

you can reproduce it by updating React Native script

@NoahSimajji
Copy link

@psbdgr8 is the fork version work on Android 14?

@psbdgr8
Copy link
Author

psbdgr8 commented Apr 29, 2024

@NoahSimajji yes it is working with Android 14 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants