#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#BridgeLogger: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
' Dim GPanel As GraphPanelClass
Dim PowerChartAS As AcceleratedSurface
Dim panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
panel1.Initialize("")
Activity.AddView(panel1,0,0,100%x,50%y)
PowerChartAS.Initialize("PCAS",True)
panel1.AddView(PowerChartAS,0,0,panel1.Width,panel1.Height)
PowerChartAS.StartRegularDraw(100)
Log("Initializing Labels")
Dim sv As ScrollView
sv.Initialize(100)
Activity.AddView(sv,0,50%y,100%x,100%y)
Dim PosY As Int=0
Dim lbl As Label
For i=0 To 10000
lbl.Initialize("")
lbl.Text=i
sv.Panel.AddView(lbl,10dip,PosY,100%x,40dip)
PosY=PosY+40dip
Next
sv.Panel.Height=PosY
MemoryUsage
End Sub
Sub PCAS_draw(ac As AS_Canvas)
For i=1 To 5
ac.DrawCircle(Rnd(0,panel1.Width),Rnd(0,panel1.Height),5dip,Colors.Green,True,0,True)
Next
End Sub
Public Sub MemoryUsage As String
Dim r As Reflector
Dim Text As String
Dim MaxMemory As Long
Dim FreeMemory As Long
Dim TotalMemory As Long
Dim UsedMemory As Long
Dim TotalFree As Long
r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null)
MaxMemory = r.RunMethod("maxMemory")
FreeMemory = r.RunMethod("freeMemory")
TotalMemory = r.RunMethod("totalMemory")
UsedMemory = TotalMemory - FreeMemory
TotalFree = MaxMemory - UsedMemory
Text = " Max Memory = " &NumberFormat2((MaxMemory/(1024*1024)), 1, 2, 2, True) &" MB" _
&CRLF &" Total Free = " &NumberFormat2((TotalFree/(1024*1024)), 1, 2, 2, True) &" MB" _
&CRLF &" Total Memory = " &NumberFormat2((TotalMemory/(1024*1024)), 1, 2, 2, True) &" MB" _
&CRLF &" Used Memory = " &NumberFormat2((UsedMemory/(1024*1024)), 1, 2, 2, True) &" MB" _
&CRLF &" Free Memory = " &NumberFormat2((FreeMemory/(1024*1024)), 1, 2, 2, True) &" MB"
Log(DateTime.Now&" Max Memory = " & NumberFormat2((MaxMemory / (1024*1024)), 1, 2, 2, True) & " MB")
Log(DateTime.Now&" Total Free = " & NumberFormat2((UsedMemory / (1024*1024)), 1, 2, 2, True) & " MB")
Log(DateTime.Now&" Total Memory = " & NumberFormat2((TotalMemory / (1024*1024)), 1, 2, 2, True) & " MB")
Log(DateTime.Now&" Used Memory = " & NumberFormat2((UsedMemory / (1024*1024)), 1, 2, 2, True) & " MB")
Log(DateTime.Now&" Free Memory = " & NumberFormat2((FreeMemory / (1024*1024)), 1, 2, 2, True) & " MB")
Return Text
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub