Capture android screen [duplicate]

亡梦爱人 提交于 2019-12-11 00:23:58

问题


How can I programmatically perform a screen capture on an Android phone?


回答1:


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.




回答2:


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




回答3:


try something like this:

View v1=childView.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm=v1.getDrawingCache();
if(bm!=null){
    //save the file
}


来源:https://stackoverflow.com/questions/4089383/capture-android-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!