电脑显示Android手机屏幕——Android Screen Monitor

1.下载 Android Screen Monitor

http://code.google.com/p/android-screen-monitor/
(1) 下載 ASM_2_40.zip 并解压缩, 取得 asm.jar
(2) 将 asm.jar 复制到D:\android-sdk\platform-tools目录下

2. 执行 Android Screen Monitor

win+R ==》 运行cmd控制台

进入D:\android-sdk\platform-tools 执行下面命令:

> java -jar asm.jar


打开后,手机连接到电脑,在电脑上会出现手机的屏幕

转载:http://blog.chinaunix.net/uid-24129645-id-3549884.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android获取屏幕显示内容有两种方式: 1. 使用MediaProjection API 使用MediaProjection API可以截屏并将屏幕上的内容转换为视频流,然后可以对视频流进行处理。以下是获取屏幕截图的代码示例: ``` private MediaProjectionManager mMediaProjectionManager; private MediaProjection mMediaProjection; private ImageReader mImageReader; private void startScreenCapture() { mMediaProjectionManager = (MediaProjectionManager) getSystemService(MEDIA_PROJECTION_SERVICE); Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent(); startActivityForResult(captureIntent, REQUEST_CODE); mImageReader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 2); mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, resultData); mMediaProjection.createVirtualDisplay("ScreenCapture", width, height, densityDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), null, null); } private void stopScreenCapture() { if (mMediaProjection != null) { mMediaProjection.stop(); mMediaProjection = null; } if (mImageReader != null) { mImageReader.close(); mImageReader = null; } } ``` 2. 使用AccessibilityService 使用AccessibilityService可以获取屏幕上的所有视图,并对其进行操作。以下是获取屏幕上所有TextView的代码示例: ``` public class MyAccessibilityService extends AccessibilityService { @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { AccessibilityNodeInfo rootNode = getRootInActiveWindow(); if (rootNode != null) { List<AccessibilityNodeInfo> textViews = rootNode.findAccessibilityNodeInfosByViewId("android:id/text1"); for (AccessibilityNodeInfo textView : textViews) { Log.d(TAG, "TextView text: " + textView.getText()); } } } } @Override public void onInterrupt() {} @Override protected void onServiceConnected() { super.onServiceConnected(); AccessibilityServiceInfo config = new AccessibilityServiceInfo(); config.eventTypes = AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED; config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; config.flags = AccessibilityServiceInfo.DEFAULT; setServiceInfo(config); } } ``` 需要注意的是,使用AccessibilityService获取屏幕内容需要用户授权。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值