Android Question How to mirror Windows PC screen to an Android Device

derez

Expert
Licensed User
If you want to build it yourself, here are key elements:
1. in the pc create a b4j server with this handle sub for the screen picture:
B4X:
Public Sub Handle(req As ServletRequest, resp As ServletResponse)
    robot.ScreenCurrentRectangleSetAsArbitrary(0,0,1280,720)
    img  = robot.ScreenCaptureAsByteArray
    Dim su As StringUtils
    resp.Write("<img width=1280 height=720 src='data:image/png;base64,")
    resp.Write(su.EncodeBase64(img))
    resp.Write("'/img>").write("</br>")
 
End Sub
2. in the device call the server specific handler and in the job_done sub do this:
B4X:
        Dim st As String = Job.GetString
            Dim su As StringUtils
            Dim barr() As Byte
            barr = su.DecodeBase64(st)
            Dim InputStream1 As InputStream
            InputStream1.InitializeFromBytesArray(barr, 0, barr.Length)
            Dim bmp As Bitmap
            bmp.Initialize2(InputStream1)
            iv.SetBackgroundImage(bmp)
            iv.Visible = True
The screen image is displayed on the iv imageview.
Robot is an object from jAWTRobot library.
 
Top