Android Question Screenshot / Picture

MarcoRome

Expert
Licensed User
Longtime User
Hi all.
I would like to capture the screen of my app as this:
Screenshot_20170614-131734.jpg


Now if i combine with button ( Home + another button ) i have this result that you see up.
If i utilize this code:

B4X:
DateTime.DateFormat = "yyyyMMdd"
    DateTime.TimeFormat = "HHMMSS"
    Dim now As Long = DateTime.now

    Dim filename As String = "BC_" & Starter.NumeroDDT &"_"& now & ".jpeg"
    Dim Obj1, Obj2 As Reflector
    Dim bmp As Bitmap
    Dim c As Canvas
    Obj1.target = Obj1.GetActivityBA
    Obj1.target = Obj1.GetField("vg")
    bmp.InitializeMutable(Activity.Width,Activity.Height)
    c.Initialize2(bmp)
    Dim args(1) As Object
    Dim types(1) As String
    Obj2.target = c
    Obj2.target = Obj2.GetField("canvas")
    args(0) = Obj2.target
    types(0) = "android.graphics.Canvas"
    Obj1.RunMethod4("draw", args, types)
    Dim out As OutputStream
    out = File.OpenOutput(File.DirRootExternal , filename, False)
    bmp.WriteToStream(out, 100, "JPEG")
    out.Close

i have this result:
BC_201600001913_1497437661912.jpg


Any idea ??
Thank you very much
Marco
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Upvote 0
Top