STARTER
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public mysql As JdbcSQL
Private driver As String = "com.mysql.jdbc.Driver"
Private jdbcUrl As String = "jdbc:mysql://SERVER/DATABASE"
Private Username As String = "username"
Private Password As String = "password"
Dim ConnectTmStart As Long
End Sub
Public Sub Connect As ResumableSub
ConnectTmStart =DateTime.Now
mysql.InitializeAsync("mysql", driver, jdbcUrl, Username, Password)
Wait For mysql_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
Log(LastException)
Else
Log("Connected: " & (DateTime.Now - ConnectTmStart) & "ms")
End If
Return Success
End Sub
Sub CloseConnection
mysql.Close
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
--------------
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("maincontackt")
Wait For (CallSub(Starter,"Connect")) Complete (Success As Boolean)
If Success Then
Listadata
End If
End Sub
--------------------------------------------------------------------------------------------
Sub Listadata
Dim active = "Yes"
Dim company = "-1"
Listv_c.Clear
Sleep(0)
Try
' ProgressDialogShow2("please wait..",False)
Dim sf As Object = Starter.mysql.ExecQueryAsync("mysql", "select f_company,mobile from m_database where f_contact Like '" & company & "%' AND status Like '" & active & "%' ORDER BY f_contact Asc", Null)
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
'Log(Crsr.GetString("f_contact"))
Listv_c.Add(CreateListItem(Crsr.GetString("f_contact"), Listv_c.AsView.Width, 60dip), Crsr.GetString("f_contact"))
Loop
Crsr.Close
' ProgressDialogHide
Activity.Title = "company"
End If
Catch
Success = False
Log(LastException)
End Try
End Sub
-----------------------------------------------------
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p2 As Panel
p2.Initialize("")
p2.SetLayout(0, 0, Width, Height)
p2.LoadLayout("maincontacktlisti")
MainLabel.Text = Text
MainLabel.TextSize = 18
But_call.Text = ""
Dim bmp As BitmapDrawable
bmp.Initialize(LoadBitmap(File.DirAssets, "phone.png"))
But_call.Background = bmp
If Activity.Title = "company" Then
But_call.Visible = True
Else
But_call.Visible = False
End If
Return p2
End Sub
--------------------------------------------------
Sub Wait(MilliSecondi As Int)
Dim Ti As Long
Ti = DateTime.Now + (MilliSecondi)
Do While DateTime.Now < Ti
DoEvents
Loop
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
'do what ever as return
If Activity.Title = "Contacts" Then
Listadata
Return True
Else
Return False
' CallSub(Starter,"CloseConnection")
' Activity.RemoveAllViews
' Activity.Finish
' Wait(100)
' ExitApplication
End If
End If
End Sub