Question

There is an app capture screen when shark android phone .

1)when app on active , capture screen without root .

2)when app back to stack , like return HOME, need root permission to capture screen .

i want to know the implement the function 2) with root permission .

in my mind, root permission means get a root shell, flush some command and exec . so i confuse how to capture screen in shell command .

Was it helpful?

Solution

If you have root or even shell permission, you can use either screenshot or screencap command, for your reference:

root@android:/system/bin # screenshot -h                                   
unknown option -- husage: screenshot [-s soundfile] filename.png
   -s: play a sound effect to signal success
   -i: autoincrement to avoid overwriting filename.png

root@android:/system/bin # screencap -h                                      
    usage: screencap [-hp] [-d display-id] [FILENAME]
       -h: this message
       -p: save the file as a png.
       -d: specify the display id to capture, default 0.
    If FILENAME ends with .png it will be saved as a png.
    If FILENAME is not given, the results will be printed to stdout.

If your device does not have these program in native, you can simply write one by yourself. The source code is here: https://android.googlesource.com/platform/frameworks/base/+/master/cmds/screencap/screencap.cpp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top