How to Prevent Screenshots in android kivy app???

218 views
Skip to first unread message

SurfaceHeaven

unread,
Jan 5, 2022, 2:56:01 AM1/5/22
to Kivy users support
any idea? how to prevent SS and screen recordings in android app build by kivy?

Robert

unread,
Jan 5, 2022, 12:48:39 PM1/5/22
to Kivy users support
In general you can't in can't app because of the 'analog hole' - anybody with a camera can photo/video your running app.

That said Android provided the functionality to prevent screen capture, and you can get to this via mActivity, and Pyjnius.


From a Kivy Android app you can getWindow() like this:

from android import mActivity
 mActivity.getWindow()

You can get the FLAG literals like this
(I didn't check if they are actually in the View class, if not adjust accordingly)

 from jnius import autoclass
View = autoclass('android.view.View')

Abdoh Fawze

unread,
Jan 5, 2022, 1:38:31 PM1/5/22
to kivy-...@googlegroups.com
Guys how can i use this library with pyjnius to take a screenshot for my android device , i found this api android.app.UiAutomation but i don't know how to use it correctly , All I want is a valid source that just shows me the use of that library and I also want to know how to use that class to take a screenshot.

Robert

unread,
Jan 5, 2022, 2:52:18 PM1/5/22
to Kivy users support
The original question was to prevent screenshot,
This question is about how to take screenshot, is that correct?


In general you won't find examples of using some random Android Java class from Python.
Which means you have to learn to use Pyjnius.

Alternatively use Kivy's native export_to_png

However if you want to trigger this from the buttons used by Android there will be extra work.
I have never tried this so I can't help you. But a little research suggest an experiment:

This suggests the screenshot key is 120 , seems worth testing.

You could try a quick test to see if it works

Window.bind(on_keyboard = self.whatever)

def whatever(self,window,key,*args):
        if key == 120:
              print('yes')
        return False  


Abdoh Fawze

unread,
Jan 5, 2022, 5:02:59 PM1/5/22
to kivy-...@googlegroups.com
First of all, thanks for your reply. I didn't think anyone would answer my question. I know how to use the Pyjnius library. You are specifying a Java library to be able to use its own methods and fileds but There is no specific and clear library that gives you what you need, also window in kivy is good But the screenshot of it is inside the workspace, I want it to be on all the device so that the bottom buttons of the device appear and the notification bar and everything is displayed on the screen

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3798e050-300e-4709-bc2e-8ef71ef738f4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages