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

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello

How to mirror Windows PC screen to an Android Device ?
 

derez

Expert
Licensed User
Longtime 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.
 
Upvote 0

Xfood

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.
congratulations, it would be nice to attach a small example
 
Upvote 0

derez

Expert
Licensed User
Longtime User
congratulations, it would be nice to attach a small example
The code I posted is all that is needed, I don't have a simple example, what I use is a complex server and device application which do more than just display the screen capture.
 
Upvote 0
Top