Capture android screen [duplicate]
How can I programmatically perform a screen capture on an Android phone?
You cannot do this from an android app except on a rooted phone, as you don't have permission to access the framebuffer device.
You can however do it over adb from the DDMS window of your development machine, as adb runs in the graphics group which has permission to the framebuffer.
If you want to do something similar in native code on a rooted device, look at the sources to the adb daemon.
EDIT: It appears this may be changing and there may be non-root capability in more recent android releases, but I'm not sure of the details.
Here's a sample of how to convert a view to a bitmap. Just grab your top view and have at it. This absolutely works and you ABSOLUTELY don't need to have a rooted device for this!
http://www.brighthub.com/mobile/google-android/articles/30676.aspx
try something like this:
View v1=childView.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm=v1.getDrawingCache();
if(bm!=null){
//save the file
}
精彩评论