Android Question Protect App from ScreenCapture

hibrid0

Active Member
Licensed User
Longtime User
Hi guys, I'm making an small app for a client and he want to protect the images showed from an screen capture.

Can I detect the ScreenCapture Method to show an Imageview for protect the real image?
Prevent Screen Capture
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
My Banks mobile app does this. I'm not sure how it is implemented though.
 
Upvote 0

hibrid0

Active Member
Licensed User
Longtime User
My Banks mobile app does this. I'm not sure how it is implemented though.
I'm thinkin on intercept the key Volume and I dont know if the powerKey will intercept.
If I will intercept both the show an ImagenView for 2 o 3 Seconds saying, "You Cannot Make screenshots from our App".

But I'm asking before to start it, maybe has a better way to do it.
I found this https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#setScreenCaptureDisabled(android.content.ComponentName, boolean)

But I dont know how to use setScreenCaptureDisabled()
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Volume key isn't the only way to take a screenshot. My Xiaomi has a soft button in the notification drawer.

Im sure someone will be able to explain how to use setScreenCaptureDisabled.
 
Upvote 0

hibrid0

Active Member
Licensed User
Longtime User
Maybe Found the solución here:
https://www.b4x.com/android/forum/threads/disable-screen-capture-functionality.35753/

I go to try.

I confirmed this solution work on my device. Just Insert this code starting the Activity_Create

B4X:
Sub Activity_Create(FirstTime As Boolean)
#If Java
import android.annotation.TargetApi;
import android.content.Context;
import android.view.WindowManager.*;
public void _onCreate() {
    this.getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
}
#End If

When I try to capture, show a message saying Can't capture, maybe memory is full.
Or something like that.

I love B4A! And B4X Forum
 
Last edited:
Upvote 0

AriGharavi

Member
Thank you, it's work for me but how I can disable it?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…