位置: 编程技术 - 正文

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中使用

  • 税务局退给企业的多交的所得税该怎样帐务处理?
  • 一般纳税人哪些可以开3%的发票吗
  • 小规模企业所得税2023年税收政策
  • 城建税和教育费附加可以税前扣除吗
  • 购买地瓜
  • 财务报表与分析课后答案
  • 自然人个税申报换电脑数据怎么合并
  • 公司收到红字发票怎么开
  • 开票时显示没有原票抄报信息
  • 平均分摊法计算公式
  • 装饰设计事务所平面图
  • 托收承付的逾期怎么处理
  • 个人设备卖给公司
  • 货物及劳务税目
  • 视同销售税率如何确定?
  • 外购商品计入
  • 付给农民的扶贫款企业如何做账?
  • 以公司买房
  • 研发部门房租可以抵税吗
  • 视同销售存货账务处理方法是什么?
  • 企业进口应税物资在进口环节应交的消费税,应计入
  • 承包承租经营单位是什么意思
  • 金税四期上线了吗?
  • 企业报税网上申报
  • 增值税进项抵扣完了还上附加税吗
  • 耗材会计分录做账怎么做
  • 企业生产销售白酒取得的下列款项中,应并入
  • 电脑进入bios关机
  • 交付是不是法律行为
  • macbook直接显示桌面
  • 微软输入法卸载不了
  • 收到供应商现金怎么入账
  • 建筑业主营业务收入二级科目有哪些
  • ksysslim.exe是什么
  • ati2sgag.exe进程安全吗 ati2sgag进程信息查询
  • 为什么磁盘会消失
  • 所有者权益会计要素包括
  • php7.0新特性
  • 最常用的基金业务
  • vuecli3创建项目的过程
  • 差旅费住宿费专票抵扣联贴在哪里
  • ptech模型
  • 零申报有哪些
  • java计数器的用法
  • 股权转让 收益
  • 预缴增值税附加税
  • 按月计提固定资产折旧算收入吗
  • centos执行sh
  • 代缴职工社保是啥意思
  • 小规模出售固定资产账务处理
  • 基建罚款支出计算方法
  • 什么叫公关费用
  • 金税盘的维护费怎么报税
  • 代扣代缴预提所得税10%是什么意思
  • 计提社保个人部分会计分录
  • 小微企业不用缴纳社保可以吗现在
  • 对公账户怎么打印
  • 会议费是指参加会议还是举办会议
  • 合并编制报表主要有哪几种
  • Vista下jusched.exe进程与禁用
  • Ubuntu Linux 7.04QQ、MSN 安装和使用方法
  • ubuntu系统升级到18
  • u盘制作winpe启动盘
  • win8怎么样的
  • 电脑ahci模式什么意思
  • win8怎么设置桌面
  • linux如何使用数据库
  • win7系统打不开网络和共享中心
  • win7旗舰版升级win10教程
  • js的三种循环
  • python redis hmset
  • Linux中的host命令应用实例详解
  • cmd下copy命令
  • unity 3d场景2d角色
  • 安卓百分百
  • 安卓初始化
  • 手滑式手机是什么意思
  • 网上办税如何打印电子凭证
  • 国家税务总局核定的该车最低计税价格
  • 烟酒税收占比
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设