Android Question how to invoke system screen shot

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi,

is there a way to invoke the system screenshot operation programmatically?

i need to take my activity's screenshot and i want it to be store in screenshots folder as if it was taken by the operating system, exactly as if the user pressed the screenshot button or slided the screen or any other way

thanks...
 
Make a Panel (declared as B4XView) as the first view in your Layout.
Make it big as the whole layout/display.
Put yout layout inside this panel.
When you need the Screenshot call
B4X: Copy
dim b as B4XBitmap = Panel1.Snapshot    'Supposing the Panel is called Panel1
and then save the bitmap where you need.
This is for Activity project, that should be avoided nowadays.
If you make a B4XPages project it will be even more simple.
No need to make all the things about the transparent panel.
Just call
B4X: Copy
dim b as B4XBitmap = Root.Snapshot
 
Last edited:
Upvote 0
Make a Panel (declared as B4XView) as the first view in your Layout.
Make it big as the whole layout/display.
Put yout layout inside this panel.
When you need the Screenshot call
B4X: Copy
dim b as B4XBitmap = Panel1.Snapshot    'Supposing the Panel is called Panel1
and then save the bitmap where you need.
This is for Activity project, that should be avoided nowadays.
If you make a B4XPages project it will be even more simple.
No need to make all the things about the transparent panel.
Just call
B4X: Copy
dim b as B4XBitmap = Root.Snapshot
thank you
i'm not sure it is what i was looking for
i need to activate the os screenshot so it will be transparent for the app and store the image in screenshot folder
my app is an existing activity app and i do not want to start turning it upside down now
so what i need is - how to activate the os print screen as if the user did it but programmatically
 
Upvote 0
I think that it's not possible to invoke the System Screenshot.
But I could be wrong.
Every day that pass it looks like the OS is the King (ok, that's normal) and our apps are Unwanted Intruders. ?
 
Upvote 0

Not sure if it will work with SDK = 31 but you can try. If it does work you need to handle the bitmap I.e convert it to PNG and save it. The do with the png whatever it is you want to do with it.
 
Upvote 0

Not sure if it will work with SDK = 31 but you can try. If it does work you need to handle the bitmap I.e convert it to PNG and save it. The do with the png whatever it is you want to do with it.
thank you Johan
i will give it a try
currently i'm on another issue i have - will post a new post for it shortly
 
Upvote 0
Back
Top