Hi
i parse a File (GPX) in a Service and Write it to a SQLite DB. (Activity call the ParseGPXFile Sub)
The Code:
With ProgDialogAsync i will show ProgressDialog. Its ab Sub in the Main Activity.
The Code:
The Sub is Calling, unfortunately the Progressdialog is not showing.
What ist wrong or what can i do to show the User a "please Wait" with the actual status?
i parse a File (GPX) in a Service and Write it to a SQLite DB. (Activity call the ParseGPXFile Sub)
The Code:
B4X:
Sub Process_Globals
Dim parser As SaxParser
Dim gpx_count, gpx_count_tmp As Long
Dim lati, loni, SumName, cmt As String
Dim sql_g_in As SQL
Dim query_gpx As String
end sub
Sub ParseGPXFile
'--- Parser
If File.Exists(File.DirInternal,"Pos.db") = False Then
sql_g_in.Initialize(File.DirInternal, "Pos.db", True)
query_gpx="CREATE TABLE Berge (id INTEGER PRIMARY KEY AUTOINCREMENT, Berg TEXT, Lat TEXT, Lon TEXT, Cmt TEXT, Loc Text)"
sql_g_in.ExecNonQuery(query_gpx)
Else
If sql_g_in.IsInitialized =False Then sql_g_in.Initialize(File.DirInternal, "Pos.db", True)
End If
Dim In As InputStream = File.Openinput(File.DirInternalCache, "DownloadGPXFile.gpx")
parser.Initialize
parser.Parse(In,"parser")
In.Close
sql_g_in.Close
ProgressDialogHide
ToastMessageShow(Starter.loc.Localize("txt_fin"),True)
End Sub
'Parser Routinen
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
If Name="wpt" Then
lati = Attributes.GetValue2("","lat")
loni = Attributes.GetValue2("","lon")
End If
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
If parser.Parents.IndexOf("wpt") > -1 Then
If Name = "name" Then
SumName= Text.ToString
Else If Name = "cmt" Then
cmt= Text.ToString
End If
End If
Private m As Map
If Name="sym" Then
Dim Matcher1 As Matcher
Dim loc As String
Matcher1 = Regex.Matcher("[A-Z]{2}\d{2}[A-Z]{2}",cmt)
Do While Matcher1.Find
loc=Matcher1.Match
Loop
query_gpx="INSERT INTO Berge VALUES(NULL,?,?,?,?,?)"
sql_g_in.ExecNonQuery2(query_gpx, Array As String(SumName,lati,loni,cmt.Replace(loc,""),loc))
gpx_count=gpx_count+1
gpx_count_tmp=gpx_count_tmp+1
If gpx_count_tmp >=10 Then
gpx_count_tmp=0
CallSub2(Main,"ProgDialogAsync","Lade Summit # " & gpx_count)
End If
End If
End Sub
With ProgDialogAsync i will show ProgressDialog. Its ab Sub in the Main Activity.
The Code:
B4X:
Sub ProgDialogAsync(text As String) As ResumableSub
Starter.cl.lg("ProgDialogAsync: " & text)
ProgressDialogShow2(text,False)
#if release
Sleep(0)
#end if
Return True
End Sub
The Sub is Calling, unfortunately the Progressdialog is not showing.
What ist wrong or what can i do to show the User a "please Wait" with the actual status?