我如何通过android.I屏幕捕获的意思是我想编写一个程序,使screen.any链接截图感谢,谢谢大家以屏幕的screeshot通过Android手机
-1
A
回答
1
我使用此代码截图我的APP(你不能拍照的其他应用程序):
@SuppressLint("SimpleDateFormat")
protected final static boolean shoot
(final View v, final String appName)
{
// Get the bitmap from the view
v.setDrawingCacheEnabled(true);
boolean isOK = false;
final Bitmap bmp = v.getDrawingCache();
final SimpleDateFormat sdf = new SimpleDateFormat("[email protected]");
final Calendar cal = Calendar.getInstance();
// Set file properties
fileJPG = appName + "_" + sdf.format(cal.getTime());
/*
Create a path where we will place our picture in the user's public
pictures directory. Note that you should be careful about what you
place here, since the user often manages these files.
For pictures and other media owned by the application, consider
Context.getExternalMediaDir().
*/
final File path =
Environment.getExternalStoragePublicDirectory
(
Environment.DIRECTORY_DCIM + "/Your_App_Name/"
);
// Make sure the Pictures directory exists.
if(!path.exists())
{
path.mkdirs();
}
final File file = new File(path, fileJPG + ".jpg");
try
{
final FileOutputStream fos = new FileOutputStream(file);
final BufferedOutputStream bos =
new BufferedOutputStream(fos, 8192);
bmp.compress(CompressFormat.JPEG, 85, bos);
bos.flush();
bos.close();
fileJPG = file.getPath();
isOK = true;
}
catch (final IOException e)
{
e.printStackTrace();
}
return isOK;
}
3
这不是尽可能轻松地按照你的意愿去做。出于安全原因,没有官方的API。
这里是你的选择:
- 使用撷取画面命令行工具:需要root权限,在所有手机
- 获取帧缓冲区没有安装:需要root
- 使用android-screenshot-library:需要ADB连接为开始
相关问题
- 1. 以Android手机的打印屏幕?
- 2. 点击android手机屏幕
- 3. Android屏幕在不同的手机上
- 4. 手机屏幕上的Android绘图
- 5. Android手机的屏幕位置发现
- 6. Android手机屏幕有多大?
- 7. Android UI LinearLayout出“手机屏幕”
- 8. Android将手机数据写入屏幕
- 9. Android根植手机屏幕截图
- 10. PIN码屏幕手机间隙android
- 11. QRCODE图像显示Android手机屏幕
- 12. Android的 - 设置壁纸,以适应手机屏幕尺寸
- 13. 我可以获得屏幕android手机的大小吗?
- 14. 手机屏幕上的双击手势
- 15. 通过iframe模拟手机屏幕尺寸
- 16. 如何通过CSS媒体查询区分手机和屏幕?
- 17. 引导手机屏幕
- 18. android通过手指在屏幕上移除线条
- 19. Xamarin的Android FlyOutMenu通过Garuma - 多屏幕
- 20. 无法通过Android Market排除此应用的小屏手机
- 21. Android Studio:手机预览,只显示屏幕,而不是屏幕的周围
- 22. android通过gridview填充所有屏幕
- 23. 如何通过ADB锁定Android屏幕?
- 24. 保存录制的手机屏幕
- 25. 手机屏幕内的可见区域
- 26. 添加到手机上的主屏幕
- 27. 手机屏幕上的显示块
- 28. UIWebview的contentSize不适合手机屏幕
- 29. 调整手机屏幕的靴带行
- 30. 渲染大屏幕版本的手机
您的应用程序或任何应用程序? –
什么?可以给我详细信息 – sakir
您想截取自己的应用或任何应用的截图吗? –