位置: 编程技术 - 正文

PC获取手机截图、复制文件、安装APK(手机截取电脑屏幕)

编辑:rootadmin

推荐整理分享PC获取手机截图、复制文件、安装APK(手机截取电脑屏幕),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:电脑手机截图快捷键,手机截取电脑屏幕,手机屏幕截图在电脑的什么文件夹,手机截取电脑屏幕,pc获取手机截图的软件,手机截图用电脑怎么找,手机截图用电脑怎么找,pc获取手机截图的软件,内容如对您有帮助,希望把文章链接给更多的朋友!

PC获取手机截图、复制文件、安装APK(手机截取电脑屏幕)

我在eoe上的帖子的链接

PC获取手机截图、复制文件、安装 ,添加了 从电脑中文件复制到设备、将APK文件安装到设备的功能。(ddmlib.jar这个包在SDK目录下tools中lib文件夹下)

package cc.practise;import java.text.SimpleDateFormat;public class Main { /** * @param args */ public static void main(String[] args) { DeviceManager dm = new DeviceManager(0); //支持多个手机端设备管理,0表示第一个连接的设备 dm.getScreenShot(" "手机截图_"&#;toDateTime(System.currentTimeMillis())); // screenShot.InstallPackage(" dm.getFileList();//获取手机存储目录列表 dm.pullFile("D:\","/mnt/sdcard/","music.aac");//将电脑中 dm.InstallPackage("D:\WoChaCha.apk");//将一个apk文件安装到手机中 } //日期的转换 private static String toDateTime(long time) { //初始化Formatter的转换&#;式。 SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒"); return formatter.format(time); }}[/mw_shl_code]DeviceManager类[mw_shl_code=java,true]package cc.practise;import java.awt.image.BufferedImage;import java.awt.image.RenderedImage;import java.io.File;import java.io.IOException;import javax.imageio.ImageIO;import com.android.ddmlib.AdbCommandRejectedException;import com.android.ddmlib.AndroidDebugBridge;import com.android.ddmlib.FileListingService;import com.android.ddmlib.FileListingService.FileEntry;import com.android.ddmlib.IDevice;import com.android.ddmlib.InstallException;import com.android.ddmlib.RawImage;import com.android.ddmlib.ShellCommandUnresponsiveException;import com.android.ddmlib.SyncException;import com.android.ddmlib.TimeoutException;public class DeviceManager { public IDevice device ; /** * 构造函数,默认获取第一个设备 */ public DeviceManager(){ AndroidDebugBridge.init(false); device = this.getDevice(0); device.getFileListingService(); System.out.println("设备信息:"&#;"getAvdName"&#;device.getAvdName()&#;"--getName"&#;device.getAvdName()&#;"--getSerialNumber"&#;device.getSerialNumber()&#;"--getProperty"&#;device.getProperty("what")); fileList=device.getFileListingService(); } /** * 构造函数,指定设备序号 * @param deviceIndex 设备序号 */ public DeviceManager(int deviceIndex){ AndroidDebugBridge.init(false); // device = this.getDevice(deviceIndex); } /** * 直接抓取屏幕数据 * @return 屏幕数据 */ public RawImage getScreenShot(){ RawImage rawScreen = null; if(device!=null){ try { rawScreen = device.getScreenshot(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AdbCommandRejectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ System.err.print("没有找到设备"); } return rawScreen; } /** * 获取图片byte[]数据 * @return 图片byte[]数据 */ public byte[] getScreenShotByteData(){ RawImage rawScreen = getScreenShot(); if(rawScreen != null){ return rawScreen.data; } return null; } /** * 抓取图片并保存到指定路径 * @param path 文件路径 * @param fileName 文件名 */ public void getScreenShot(String path,String fileName){ System.out.println("设备信息:"&#;"getAvdName"&#;device.getAvdName()&#;"--getName:--"&#;device.getAvdName()&#;"--getSerialNumber"&#;device.getSerialNumber()&#;"--getProperty"&#;device.getProperty("what")); RawImage rawScreen = getScreenShot(); if(rawScreen!=null){ Boolean landscape = false; int width2 = landscape ? rawScreen.height : rawScreen.width; int height2 = landscape ? rawScreen.width : rawScreen.height; BufferedImage image = new BufferedImage(width2, height2, BufferedImage.TYPE_INT_RGB); if (image.getHeight() != height2 || image.getWidth() != width2) { image = new BufferedImage(width2, height2, BufferedImage.TYPE_INT_RGB); } int index = 0; int indexInc = rawScreen.bpp >> 3; for (int y = 0; y < rawScreen.height; y&#;&#;) { for (int x = 0; x < rawScreen.width; x&#;&#;, index &#;= indexInc) { int value = rawScreen.getARGB(index); if (landscape) image.setRGB(y, rawScreen.width - x - 1, value); else image.setRGB(x, y, value); } } try { ImageIO.write((RenderedImage) image, "PNG", new File(path &#; "/" &#; fileName &#; ".png")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /** * 获取得到device对象 * @param index 设备序号 * @return 指定设备device对象 */ private IDevice getDevice(int index) { IDevice device = null; AndroidDebugBridge bridge = AndroidDebugBridge .createBridge();// 如果代码有问题请查看API,修改此处的参数&#;试一下 waitDevicesList(bridge); IDevice devices[] = bridge.getDevices(); for (int i = 0; i < devices.length; i&#;&#;) { System.out.println(devices.toString()); } if(devices.length < index){ //没有检测到第index个设备 System.err.print("没有检测到第" &#; index &#; "个设备"); } else { if (devices.length-1>=index) { device = devices[index]; } else { device = devices[0]; } } return device; } /** * 等待查找device * @param bridge */ private void waitDevicesList(AndroidDebugBridge bridge) { int count = 0; while (bridge.hasInitialDeviceList() == false) { try { Thread.sleep(); count&#;&#;; } catch (InterruptedException e) { } if (count > ) { System.err.print("等待获取设备超时"); break; } } } public void InstallPackage(String apkFilePath) { try { device.installPackage(apkFilePath, false, ""); } catch (InstallException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private FileListingService fileList; private FileEntry temp; /** * 测试打印出存储目录列表 * @return */ public String[] getFileList() { fileList=device.getFileListingService(); FileEntry[] arrayFileEntry; try { // String str=fileList.getRoot().findChild(fileList.DIRECTORY_SDCARD).getFullPath(); arrayFileEntry=fileList.getChildrenSync(fileList.getRoot()); // System.out.println("print story path:"&#;fileList.getRoot().findChild(fileList.DIRECTORY_SDCARD).getFullPath()); for (int i = 0; i < arrayFileEntry.length; i&#;&#;) { if(arrayFileEntry.getFullPath().equals("/mnt")) { System.out.println("我找到mnt目录了!"); FileEntry[] array=fileList.getChildrenSync(arrayFileEntry); if(array!=null) for (int j = 0; j < array.length; j&#;&#;) { System.out.println("mnt目录下:"&#;array[j].getFullPath()); } } System.out.println("Path:"&#;arrayFileEntry.getFullPath()); } } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AdbCommandRejectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ShellCommandUnresponsiveException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /** * 将一个文件从电脑上复制到手机指定的目录下 * @param localPath:本地的目录 * @param remotePath:手机的目录 * @param fileName:文件名称 */ public void pullFile(String localPath,String remotePath,String fileName) { /* try { FileEntry[] arrayTemp=fileList.getChildrenSync(temp); for (int i = 0; i < arrayTemp.length; i&#;&#;) { if(arrayTemp.getFullPath().equals(remotePath)) { System.out.println("I find ttpod path!"); }else { System.out.println("没有找到设备中的目录:"&#;remotePath); } System.out.println("arrayTemp:"&#;arrayTemp.getFullPath()); }*/ try { device.pushFile(localPath&#;fileName,remotePath&#;fileName); } catch (SyncException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AdbCommandRejectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } /*} catch (SyncException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AdbCommandRejectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ShellCommandUnresponsiveException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ }}

ORMLite完全解析(四) 官方文档第四章、在Android中使用 官方文档的第四章原标题是UsingWithAndroid,看过前面的文档友友,看到这里可能会有点晕乎,因为从一开始就在介绍ORMLite在Android中的介绍,但是到第四章

android(6) 扇形菜单实现 一.扇形菜单的实现:借鉴了大神们的源码,那我们来看一下扇形菜单是怎么实现的:效果图:主界面布局:RelativeLayoutxmlns:android=

Android 进行单元测试难在哪-part1 原文链接:AgainstAndroidUnitTests原文作者:MatthewDupree译文出自:开发技术前线www.devtf.cn译者:chaossss校对者:tiiime状态:完成正如我在序中所说,在Android中难于进

标签: 手机截取电脑屏幕

本文链接地址:https://www.jiuchutong.com/biancheng/384301.html 转载请保留说明!

上一篇:工具类(4)图片操作工具类(工具的图)

下一篇:ORMLite完全解析(四) 官方文档第四章、在Android中使用

  • 缴纳购销合同印花税怎么算
  • 房产税纳税义务人
  • 保险公司代收车船税会计分录
  • 已经开了发票需要退款怎么处理
  • 城镇土地使用税的计税依据
  • 契税为什么计入成本
  • 按收入比例结转怎么做账
  • 房地产企业施工电费会计分录
  • 个体户不足征是否要交房产税
  • 行政事业性收据上面的角分无是右下划线吗
  • 税收用在哪些方面
  • 房产税的征收对象有哪些
  • 代开专票地税附加税申报办法
  • 怎样理解递归
  • 建材销售公司需要交哪些税
  • won11检测
  • 甲方工程扣款如何处理
  • 其他货币资金属于资产类科目
  • negro 什么意思
  • php数据库语句
  • 融资a轮之前
  • PHP:imagecolorclosesthwb()的用法_GD库图像处理函数
  • 企业的存货按照计划成本核算,期初
  • 以公允价值计量的金融资产不计提损失准备
  • 文化事业建设费减免政策
  • 企业开负数发票退货后怎么处理?
  • 利润的调增和调减
  • 公司给员工交社保是怎么交的
  • 对公账户和私人账户怎么区分
  • python condition条件变量
  • 生产油漆涂料的物质
  • 没有实收资本的股权原值
  • 公司法人的车租给公司怎么开发票
  • 公司向银行贷款还不上会怎么样
  • 零税项目
  • 增值税普票和卷式发票
  • 出差补贴要不要交个税呢?
  • ibm db2认证
  • 解决在sql脚本中怎么写
  • 白酒消费税计税价格由谁核定
  • 企业所得税视同销售的有哪些?
  • 发票做账流程
  • 主营业务收入的借贷方向
  • 内账应付账款怎么做账
  • 购买产品样品计入什么科目
  • 电商企业银行账户是什么
  • 免税申请需要什么材料
  • 应交税费核算规定最新
  • 收到增值税发票后该如何处理啊?
  • 利息支出可以抵扣进项吗
  • 公司开具电子发票是否取消纸质发票开具
  • 试制流程
  • 出纳和记账会计哪个好
  • 工业投资范围是什么
  • 怎么统计每日产量
  • windows的fn键
  • linux awk '{print $0}'
  • uca1
  • mac 鼠标调整
  • 电脑ip地址设置在哪里
  • win7由于所要求的文件丢失或损坏
  • win7系统出现问题怎么修复
  • 铁嘴王指什么动物
  • 使用css实现全兼容的方法
  • 利用的近义词
  • jquery自定义事件
  • 批处理/a
  • socket restful
  • python基础开发
  • 会用python
  • 深入理解linux内核第三版
  • eclipse自动生成
  • 辽宁省农村合作医疗2024怎么缴费
  • 安置残疾人就业增值税即征即退优惠
  • 增资注册资本
  • 重庆国税官网网址
  • 会计专业有必要读博士吗
  • 大班直播课怎么上
  • 泉州市税务局投诉电话
  • 江苏国税发票出库时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设