Is it possible to prevent screen recording while allowing screnshots in android application? I tried FLAG_SECURE, but it prevent both screenshots and screen recording simutaneously. I also tried using ContentObserver to monitor Uri changes, but this only accurately detects screenshots. If screen recording begins before the app launches and ends after the app is closed, it cannot be detected at all. Then I considered using refection with MediaProjection to determine if screen recording is happening, but reflection is not supported with target API 30+. I also attempted to use DisplayManager to monitor display chages, but this is only effective when monitoring within the app.If screen recording begins before the app launches and ends after the app is closed, it cannot be detected as well.
this.displayManager = (DisplayManager) activity.getSystemService(Context.DISPLAY_SERVICE);
this.displayListener = new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
if (isScreenRecording()) {
onScreenRecordListener.onScreenRecord(true);
enableSecureMode();
}
}
@Override
public void onDisplayRemoved(int displayId) {
onScreenRecordListener.onScreenRecord(true);
disableSecureMode();
}
@Override
public void onDisplayChanged(int displayId) {
}
};
Moreover, it seems that through DisplayManager, I can only access the app's own display, making it impossible to further determine if screen recording is taking place. Using AccessibilityService, NotificationListenerService seems to provide more accurate detection, but using these permissions for detection seems unreasonable. Plus, if permissions are required for detection, it defeats the purpose of detection in the first place.Does anyone have better detection methods? Or is the requirement to prevent screen recording while allowing screenshots unreasonable and completely impossible to implement?
Is it possible to prevent screen recording while allowing screnshots in android application? I tried FLAG_SECURE, but it prevent both screenshots and screen recording simutaneously. I also tried using ContentObserver to monitor Uri changes, but this only accurately detects screenshots. If screen recording begins before the app launches and ends after the app is closed, it cannot be detected at all. Then I considered using refection with MediaProjection to determine if screen recording is happening, but reflection is not supported with target API 30+. I also attempted to use DisplayManager to monitor display chages, but this is only effective when monitoring within the app.If screen recording begins before the app launches and ends after the app is closed, it cannot be detected as well.
this.displayManager = (DisplayManager) activity.getSystemService(Context.DISPLAY_SERVICE);
this.displayListener = new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
if (isScreenRecording()) {
onScreenRecordListener.onScreenRecord(true);
enableSecureMode();
}
}
@Override
public void onDisplayRemoved(int displayId) {
onScreenRecordListener.onScreenRecord(true);
disableSecureMode();
}
@Override
public void onDisplayChanged(int displayId) {
}
};
Moreover, it seems that through DisplayManager, I can only access the app's own display, making it impossible to further determine if screen recording is taking place. Using AccessibilityService, NotificationListenerService seems to provide more accurate detection, but using these permissions for detection seems unreasonable. Plus, if permissions are required for detection, it defeats the purpose of detection in the first place.Does anyone have better detection methods? Or is the requirement to prevent screen recording while allowing screenshots unreasonable and completely impossible to implement?
Share Improve this question asked Mar 24 at 3:20 Chance JasonChance Jason 212 bronze badges1 Answer
Reset to default 4No, there isn't. If you do manage to find some work around, don't expect it to continue to work in future versions (or past versions). The supported way to do this is the SECURE flag. Which blocks both, because the idea is that you have data that shouldn't be saved to disk. You mention AccessibilityService- you will not be allowed on the play store if you use that- only actual accessibility apps are allowed to use it, and blocking recording is not an accessibility usecase (if anything it could be argued to be the opposite, as you would possibly break screen readers or other methods).
I honestly question your need for this functionality, other than that some PM or designer thought it would be cool. If you want to block recording, you want to block screenshots as well. Otherwise they can just take a screenshot every 1/30th of a second and have a movie (or use a second device filming the screen). What functionality does it add to block one but not the other?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744262141a4565687.html
评论列表(0条)