How can I take a screenshot of a selected area of phone-screen not by any program but from code?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
EDIT: have mercy with the downvotes. It was true in 2010 when I answered the question.
All the programs which allow screenshots work only on rooted phones.
Mualig answer is very good, but I had the same problem Ewoks describes, I'm not getting the background. So sometimes is good enough and sometimes I get black text over black background (depending on the theme).
This solution is heavily based in Mualig code and the code I've found in Robotium. I'm discarding the use of drawing cache by calling directly to the draw method. Before that I'll try to get the background drawable from current activity to draw it first.
My solution is:
and
Images are saved in the external storage folder.
Short way is
Note: works only for rooted phone
Programmatically, you can run
adb shell /system/bin/screencap -p /sdcard/img.png
as belowthen read
img.png
asBitmap
and use as your wish.Along with capturing screenshot,if we want to play the tone also.We can use following code