Hi All,
Still attempting to port B4A App to B4J.
The sub below saves the Googlmap screen. It is partly converted but I can't figure out the following line:
Obj1.Target = Obj1.GetActivityBA. Obviously Obj1.GetActivityBA is not correct for B4J, but I don't know what is correct.
As usual any help greatly appreciated.
Regards Roger
Still attempting to port B4A App to B4J.
The sub below saves the Googlmap screen. It is partly converted but I can't figure out the following line:
Obj1.Target = Obj1.GetActivityBA. Obviously Obj1.GetActivityBA is not correct for B4J, but I don't know what is correct.
B4X:
Sub BtnSave_Click
Private Obj1, Obj2 As Reflector
Private args(1) As Object
Private types(1) As String
Private Out As OutputStream
'Private Rect1 As Rect
'Private Rect1 As JavaObject
Private DirPath As String = File.DirApp & "/ABT/"
Private TempImage As Image
If File.Exists(DirPath, "") = False Then File.MakeDir(DirPath, "")
If FileFlag = 0 Then 'FileFlag is set to 1 by InPutFileName Sub if valid file name.
'Take ScreenShot of Google map, save as map.png
MapEx.Snapshot(gmap, "gmap")
'Input file name
InPutFileName
Return 'Ignore
End If
'Take a screenshot and Save as ScrnShotTemp.png
Obj1.Target = Obj1.GetActivityBA 'This is the line.
Obj1.Target = Obj1.GetField("vg")
Obj2.Target = MapCanvas
Obj2.Target = Obj2.GetField("canvas")
args(0) = Obj2.Target
types(0) = "android.graphics.Canvas"
Obj1.RunMethod4("draw", args, types)
If File.Exists(DirPath, "ScrnShotTemp.png") Then File.Delete(DirPath, "ScrnShotTemp.png")
Out = File.OpenOutput(DirPath, "ScrnShotTemp.png", False)
Image1.WriteToStream(Out)
Out.Close
'Place Map on Canvas
TempImage.Initialize(DirPath, "Map.png")
'MapCanvas.Initialize.("")
MapCanvas.Initialize("")
'Rect1.Initialize(0, pnlDispLatLng.Height, 100%x, 100%y)
MapCanvas.DrawImage(TempImage, 0, 0, TempImage.Width, TempImage.Height)
'Place ScreenShot on Map
TempImage.Initialize(DirPath, "ScrnShotTemp.png")
MapCanvas.Initialize("")
'Rect1.Initialize(0, 0, 100%x, 100%y)
MapCanvas.DrawImage(TempImage, 0, 0, TempImage.Width, TempImage.Height)
'Save using FileName
Out = File.OpenOutput(DirPath, FileName, False)
'MapCanvas.Bitmap.WriteToStream(Out)
MapCanvas.Snapshot.WriteToStream(Out)
Out.Close
CustomToastMsg.ToastShow(FileName&" Saved to Directory ABT")
'Reset
If File.Exists(DirPath, "map.png") Then File.Delete( DirPath, "map.png")
If File.Exists(DirPath, "ScrnShotTemp.png") Then File.Delete( DirPath, "ScrnShotTemp.png")
FileFlag = 0
FileName = ""
DispInput.Text = ""
End Sub
As usual any help greatly appreciated.
Regards Roger