stop the user from taking the snapshot

I am currently doing a Web application, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

I have been trying to find its solution.

Hi,

Web pages can not control all or part of the client PC for security reasons & The PrintScreen button is handled by the OS of the client PC. By default it is even not passed to running applications like a web browser. The only solution is to let an application hook the keyboard input using an OS specific method. But such is not supported by JavaScript.

Even with the normal MVC framework of PHP or Node it is quite impossible to do so.


Thanks

assif_tiger wrote:

Hi,

Web pages can not control all or part of the client PC for security reasons & The PrintScreen button is handled by the OS of the client PC. By default it is even not passed to running applications like a web browser. The only solution is to let an application hook the keyboard input using an OS specific method. But such is not supported by JavaScript.

Even with the normal MVC framework of PHP or Node it is quite impossible to do so.


Thanks

Any other solution for this.


@media print {
    html, body {
       display: none;  /* hide whole page */
    }
}

This will work with print command but not with "print screen"!

And I am pretty sure there's no way to achieve that, as of  Print screen is a part of the OS, not the browser.

thanks

Hi Ramesh,

Not possible as far as I know, you can't control this from the browser. Users can always use print screen or any other tool to create a screen print, lf even if you find a way to implement your restriction in your app (which you cannot) this is still a false safety measure as any person with a phone or tablet with camera, a photo camera or video camera can still make a photo for what is on your screen.

I think you need to reconsider how useful this requirement really is.

Regards,

Daniel

Ramesh Kannan.v wrote:

I am currently doing a Web application, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

I have been trying to find its solution.

There are so many methods, let's see one of this will work or not

  • Method 1

Just add this line:

getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

Before your setContentView() method.


  • Method 2


Add following line of code in onCreate() method:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                           WindowManager.LayoutParams.FLAG_SECURE);

To enable Screen Capture:

Find for LayoutParams.FLAG_SECURE and remove the line of code.


  • Method 3


You can make your app as device/profile owner and call setScreenCaptureDisabled(). From thedocs, this api does the following:

public void setScreenCaptureDisabled (ComponentName admin, boolean disabled) Added in API level 21

Called by a device/profile owner to set whether the screen capture is disabled. Disabling screen capture also prevents the content from being shown on display devices that do not have a secure video output. See FLAG_SECURE for more details about secure surfaces and secure displays.

The calling device admin must be a device or profile owner. If it is not, a security exception will be thrown. Parameters admin Which DeviceAdminReceiver this request is associated with. disabled Whether screen capture is disabled or not.

Alternatively you can become an MDM(Mobile Device Management) partner app.OEMs provides additional APIs to their MDM partner apps to control the device.For example samsung provides api to control screen recording on the device to their MDM partners.

Currently this is the only way you can enforce screen capture restrictions.



Hi Ramesh,

In this post there is a user that say that is possible. but why do you want to do this? the user can always take a picture of the screen with a smarthphone.

Regards,

Marcelo

Sagar Rathod wrote:

Ramesh Kannan.v wrote:

I am currently doing a Web application, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

I have been trying to find its solution.

There are so many methods, let's see one of this will work or not

  • Method 1


Just add this line:

getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

Before your setContentView() method.


  • Method 2


Add following line of code in onCreate() method:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                           WindowManager.LayoutParams.FLAG_SECURE);

To enable Screen Capture:

Find for LayoutParams.FLAG_SECURE and remove the line of code.


  • Method 3


You can make your app as device/profile owner and call setScreenCaptureDisabled(). From thedocs, this api does the following:

public void setScreenCaptureDisabled (ComponentName admin, boolean disabled) Added in API level 21

Called by a device/profile owner to set whether the screen capture is disabled. Disabling screen capture also prevents the content from being shown on display devices that do not have a secure video output. See FLAG_SECURE for more details about secure surfaces and secure displays.

The calling device admin must be a device or profile owner. If it is not, a security exception will be thrown. Parameters admin Which DeviceAdminReceiver this request is associated with. disabled Whether screen capture is disabled or not.

Alternatively you can become an MDM(Mobile Device Management) partner app.OEMs provides additional APIs to their MDM partner apps to control the device.For example samsung provides api to control screen recording on the device to their MDM partners.

Currently this is the only way you can enforce screen capture restrictions.



Hi Sagar Rathod,

Can you explain briefly


Hi Ramesh,

Not possible as far as I know,

Users can always use a print screen with other tools available or snapshot with a phone/tablet with a camera.

Thanks.

Ellakkiya Selvadurai wrote:

Sagar Rathod wrote:

Ramesh Kannan.v wrote:

I am currently doing a Web application, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

I have been trying to find its solution.

There are so many methods, let's see one of this will work or not

  • Method 1


Just add this line:

getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

Before your setContentView() method.


  • Method 2


Add following line of code in onCreate() method:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                           WindowManager.LayoutParams.FLAG_SECURE);

To enable Screen Capture:

Find for LayoutParams.FLAG_SECURE and remove the line of code.


  • Method 3


You can make your app as device/profile owner and call setScreenCaptureDisabled(). From thedocs, this api does the following:

public void setScreenCaptureDisabled (ComponentName admin, boolean disabled) Added in API level 21

Called by a device/profile owner to set whether the screen capture is disabled. Disabling screen capture also prevents the content from being shown on display devices that do not have a secure video output. See FLAG_SECURE for more details about secure surfaces and secure displays.

The calling device admin must be a device or profile owner. If it is not, a security exception will be thrown. Parameters admin Which DeviceAdminReceiver this request is associated with. disabled Whether screen capture is disabled or not.

Alternatively you can become an MDM(Mobile Device Management) partner app.OEMs provides additional APIs to their MDM partner apps to control the device.For example samsung provides api to control screen recording on the device to their MDM partners.

Currently this is the only way you can enforce screen capture restrictions.



Hi Sagar Rathod,

Can you explain briefly


I have used SECURE FLAG for prevent screen capturing.