简体   繁体   中英

android taking screenshots programmaticaly Android Screenshot Library issue

What I want to achieve is to capture a current foreground activity and save to bitmap file. I need to handle taking that screenshot in a background service. I have run through many ideas, tutorials that mainly uses invoking getWindow() method and enabling cache. However that approach is useless for me - it is impossible to get reference to the foreground running activity (isn't it?) - using ActivityManager I can get only the name & package of it.

I came across the ASL ( https://code.google.com/p/android-screenshot-library/downloads/detail?name=asl-1.2.zip&can=2&q= ) which uses "native service" which is available in compiled binary file. Library's wiki note states that you have to start the native "screenshot service" by ADB using pc.

My question is: could it be possible to start that service programmaticaly through java code, something like JNI (using NDK) does?

On a rooted device, you can start the service from Java with

Runtime.getRuntime().exec("su")

On custom system, you can start the service from /init.rc .

NDK will not help, anyway. Going C does not compromise the system permissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM