简体   繁体   English

如何在Android即服务上捕获屏幕

[英]How to capture screen on android as service

Hi I'm very new to android and I just shift my work form iOS so I don't know much about android. 嗨,我是android的新手,我只是将工作形式移至iOS,所以我对android不太了解。

I want to create the android device screen monitoring app. 我想创建android设备屏幕监控应用。 Which can see other android device screen simultaneously over WiFi and also can broadcast screen to other device. 它可以通过WiFi同时查看其他android设备的屏幕,也可以将屏幕广播到其他设备。

I think of using UDP to broadcast screen by simply capturing screen and send it to host. 我想通过简单地捕获屏幕并将其发送到主机来使用UDP广播屏幕。 It's no need to be real time just show what's on their screen would be suffice. 只需显示他们的屏幕上的内容就足够了,就不必实时。

By call this method with timer 通过使用计时器调用此方法

private void captureScreen() {
    final View rootview1 = findViewById(R.id.root).getRootView();
    rootview1.setDrawingCacheEnabled(true);
    Bitmap bmp = rootview1.getDrawingCache();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 20, bytes);//lower quality faster
    byte[] byteArray = bytes.toByteArray();


    packetToSend.setData(byteArray);//send image

    rootview1.setDrawingCacheEnabled(false);


}

Now I can send view of my app and show on the host properly. 现在,我可以发送应用程序视图并正确显示在主机上。

My problem is if I run this method as service how do I find the current view while they open other application (like Browser, games, movie) or in dashboard? 我的问题是,如果我将此方法作为服务运行,当它们打开其他应用程序(如浏览器,游戏,电影)或仪表板时,如何查找当前视图?

please help 请帮忙

Thanks. 谢谢。

My problem is if I run this method as service how do I find the current view while they open other application (like Browser, games, movie) or in dashboard? 我的问题是,如果我将此方法作为服务运行,当它们打开其他应用程序(如浏览器,游戏,电影)或仪表板时,如何查找当前视图?

Fortunately, this is not possible, for blindingly obvious privacy and security reasons. 幸运的是,由于显而易见的隐私和安全原因,这是不可能的。 You are welcome to share your own UI that way (per your code); 欢迎您以这种方式(根据您的代码)共享自己的UI you cannot share other apps' UI that way. 您不能以这种方式共享其他应用的用户界面

There are various options available for use on rooted devices, though I have lost track for how well they work given recent changes to the Android UI pipeline. 在有根设备上可以使用多种选项,尽管由于最近对Android UI管道所做的更改,我无法跟踪它们的运行情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM