Hello, I have a service that starts an activity called "ScreenShot", when it calls it, it opens and takes the screenshot but its always just a blank black picture. I dont know whats happening, i've tried to make it translucent but that doesn't work either. Could someone help?
ScreenShot:
ScreenShot:
B4X:
#Region Module Attributes
#FullScreen: True
#IncludeTitle: False
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
TakeScreenshot
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub TakeScreenshot
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, "snap.png", False)
bmp.WriteToStream(Out, 100, "PNG")
Out.Close
Activity.Finish
End Sub