(Reprinted please indicate the source: http://blog.csdn.net/buptgshengod) 1. Background
The screenshot function of the android system is encapsulated by google and is also desired by everyone. After more than a month of research, the blogger finally succeeded in implementing system screenshots in the new android version, that is, version 4.3 and later. If you want to better understand this knowledge, we recommend that you first capture the source code of the android screenshot and summarize the methods of the android screenshot. The following method is followed by the content of the above two blogs. First, give me one.
2. conditions to be met
1. root mobile phone
2. source code above android4.1
3. Basic flash brush knowledge or use flash brush Software
3. Main steps (1) compile your own system
Because the SurfaceControl that controls the screenshot function is hidden in the source code by @ hide (for details, see the android screenshot source code capture ). We want to delete all the comments in this file. It turns out that only deleting "@ hide" cannot be compiled. Then run the command in the source code directory through shell.
source build/envsetup.sh
(Activate make, mm, and other commands)
Run the command again (select the version, no need)
lunch
Then run
make -j6
Install the Generated System on your mobile phone. (Tutorials are available online)
(2) compile your own sdk
Then, run the following command to generate your own sdk for removing "@ hide" from SurfaceControl.
make PRODUCT-sdk-sdk
After compiling the sdk, import it to eclipse. If we create a new project, import android. view. SurfaceControl. If no error is reported, the sdk is successfully generated.
Then you can obtain the screen by returning bitmap.
bp=SurfaceControl.screenshot(width,length);
However, this project cannot be compiled in eclipse, because we need to add the following code to AndroidManifest. xml to make the program a system-level app.
android:sharedUserId="android.uid.system"
(3) Compile the app in the source code
Put the debugged app (which can be the version provided by me) under the source code directory/packages/apps. Compile the Android. mk file (modify it as needed)
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)#LOCAL_DEX_PREOPT := falseLOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(call all-subdir-java-files)LOCAL_PACKAGE_NAME := SimpleScreenshotLOCAL_CERTIFICATE := platforminclude $(BUILD_PACKAGE)
LOCAL_CERTIFICATE := platform
The above statement indicates a system-level app.
Run the command mm to compile the generated apk and use the adb shell command to push it to the/system/apps on the mobile phone.
Provide a demon for your reference. I found it online and changed it to 4.3. If you don't know it, you can leave a message to discuss it.
Download Resources