Problem: ProgressDialogshow(...) will not be displayed on startup! Why is that?

Amalkotey

Active Member
Licensed User
Longtime User
Guten Morgen,

ich möchte, das beim Start meiner Application ein Progress-Dialog mit ProgressDialogShow(...) angezeigt werden soll. Es spielt keine Rolle, wo ich den Befehl hinsetze, denn der Dialog wird nicht angezeigt. Er soll als erster Befehl in der Sub Globals angezeigt werden und in der Sub Activity_Create, nach Abarbeitung der Sub, wieder geschlossen werden.

Ich weiss nicht wo mein Fehler steckt. Da bekanntlicher Weise, vier oder mehr Augen auch mehr sehen, als zwei Augen, möchte ich euch bitten, mal über meinen nachfolgenden Quellcode zu schauen, damit das Problem gelöst wird.

Vielen Dank für euere Hilfe im Voraus.

...

Good morning,

I wish that when I launch my application with a progress dialog to show ProgressDialogShow(...) are displayed. It does not matter where I sit command, because the dialog is not displayed. Want it to appear as the first command in the sub globals and in the sub Activity_Create, after processing the sub, to be closed again.

I do not know where is my mistake. As a known manner, four or more eyes see more than two eyes, I would ask you to visit on my next source code, so the problem is solved.

Thank you for your help in advance.

Cu
Amalkotey

B4X:
Sub Globals
   ProgressDialogShow("Installierte Apps werden ermittelt und" & CRLF & "Favoritenlise wird gelesen!")

   Dim PM As PackageManager
   Dim AllApps As Map
   Dim FavApps As Map

   Dim tabApps As TabHost
   Dim lstAllApps As ListView
   Dim lstFavApps As ListView
   Dim hLine1 As ImageView

   Dim lblLicTo As Label
   Dim lblSupportMail As Label
   Dim lblStrasse As Label
   Dim lblPLZuOrt As Label
   Dim lblUrl As Label
   Dim lblUserReg As Label
   Dim lblUserIMEI As Label

   Dim btnRegister As Button
   Dim ActivPage As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim in As Intent
   
   Dim bd As BitmapDrawable
   Dim bmp As Bitmap
   Dim bmp2 As Bitmap
   Dim imgClose As Bitmap
   Dim imgOpt As Bitmap
   Dim imgExit As Bitmap
   Dim imgOrder As Bitmap
   
   Dim Package As String
   Dim AllPackages As List
   Dim FavPackages As List
   Dim AllLabels As List
   Dim FavLabels As List
   Dim Apps As Map
   Dim Lable As String
   Dim Add As Boolean
   Dim Items As Int

   Global.Initialize
   AllApps.Initialize
   FavApps.Initialize
   AllPackages.Initialize
   FavPackages.Initialize
   AllLabels.Initialize
   FavLabels.Initialize

   Activity.LoadLayout("main")
   
   If (Global.Registered = True) Then         
   Global.FavIni.LoadDeviceIniFile(Global.cFavIniPath & "\" & Global.cFavIniFile)
      If Global.FavIni.LastError.Length = 0 Then
         Items = Global.FavIni.getValuesNumbers("Packages")
         If (Items > 0) Then
            For i = 0 To Items - 1
               Package = Global.FavIni.getKeyStringValue("Packages", "APK" & (i + 1), "")
               FavPackages.Add(Package)
            Next
         End If
         If (FavPackages.Size > 0) Then
            For i = 0 To FavPackages.Size - 1
               Package = FavPackages.Get(i)
               in = pm.GetApplicationIntent(Package)
               If in.IsInitialized Then
                  Lable = PM.GetApplicationLabel(Package)
                  FavLabels.Add(Lable)
                  FavApps.Put(Lable, Package)
               End If
            Next
         End If
      End If
   End If
   AllPackages = PM.GetInstalledPackages
   If (AllPackages.Size > 0) Then
      AllApps.Clear
      For i = 0 To AllPackages.Size - 1
         Package = AllPackages.Get(i)
         in = pm.GetApplicationIntent(Package)
         If (in.IsInitialized) Then
            Lable = PM.GetApplicationLabel(Package).Trim
            AllLabels.Add(Lable)
            AllApps.Put(Lable, Package)
         End If
      Next
   Else
      Msgbox("Keine Applikationen installiert!" & CRLF & "Programm wird beendet.", "Error")
      MenueClick(4)
   End If

   lstAllApps.Initialize("lstAllApps_ItemClick")
   lstFavApps.Initialize("lstFavApps_ItemClick")
   
   imgClose.Initialize(File.DirAssets, "Close.png")
   imgOpt.Initialize(File.DirAssets, "options.png")
   imgExit.Initialize(File.DirAssets, "exit.png")
   imgOrder.Initialize(File.DirAssets, "ordering.png")
   btnRegister.Initialize("Click")
   
   If (Global.Registered = False) Then
      Activity.AddMenuItem2("Bestellung erstellen", "mnuSendOrder", imgOrder)
      Lable = "Service " 
   End If
   Activity.AddMenuItem2("Einstellungen", "mnuSettings", imgOpt)
   Activity.AddMenuItem2(Lable & "schliessen", "mnuAppClose", imgClose)
   Activity.AddMenuItem2(Lable & "beenden", "mnuAppExit", imgExit)
   
   lstAllApps.Clear
   lstFavApps.Clear
   ActivPage = 0
   
   bmp = LoadBitmap(File.DirAssets, "allApps.png")
   bmp2 = LoadBitmap(File.DirAssets, "allAppsSel.png")
   tabApps.AddTabWithIcon ("alle Apps", bmp, bmp2, "AllApps")
   If (Global.Registered) Then
      bmp = LoadBitmap(File.DirAssets, "favApps.png")
   Else
      bmp = LoadBitmap(File.DirAssets, "NonfavApps.png")
   End If
   tabApps.AddTabWithIcon ("Favoriten", bmp, bmp, "FavApps")
   bmp = LoadBitmap(File.DirAssets, "about.png")
   tabApps.AddTabWithIcon ("Über", bmp, bmp, "About")
   SetAppState

   lstAllApps.ScrollingBackgroundColor = Colors.Transparent
   lstAllApps.SingleLineLayout.ItemHeight = 100dip
   lstAllApps.SingleLineLayout.Label.TextSize = 20
   lstAllApps.SingleLineLayout.Label.TextColor = Colors.Blue
   lstAllApps.SingleLineLayout.Label.Gravity = Gravity.CENTER
   lstAllApps.FastScrollEnabled = True

   lstFavApps.ScrollingBackgroundColor = Colors.Transparent
   lstFavApps.SingleLineLayout.ItemHeight = 100dip
   lstFavApps.SingleLineLayout.Label.TextSize = 20
   lstFavApps.SingleLineLayout.Label.TextColor = Colors.Blue
   lstFavApps.SingleLineLayout.Label.Gravity = Gravity.CENTER
   lstFavApps.FastScrollEnabled = True

   lblUserIMEI.Text = "IMEI-Nr.: " & Global.PhoneId.GetDeviceId

   tabApps.CurrentTab = 0
   If (Global.Registered = True) AND (FavLabels.Size > 0) Then
      FavLabels = Global.FavIni.sortList(FavLabels)
      For i = 0 To FavLabels.Size - 1
         Package = FavApps.Get(FavLabels.Get(i))
         Lable = PM.GetApplicationLabel(Package)
         Add = True
         If (Package.ToLowerCase = "esdaso.tools.appsfavorites") AND (Lable.ToLowerCase = "application-favorites") Then
            Global.cVersion = " v" & pm.GetVersionName(Package)
            Global.cTitle = Lable & Global.cVersion
            Activity.Title = Global.cTitle
            Add = False
         End If
         If Add Then
            bd = PM.GetApplicationIcon(Package)
            lstFavApps.AddTwoLinesAndBitmap(Lable, Package, bd.Bitmap)
            tabApps.CurrentTab = 1
         End If
      Next
   End If
   If (AllLabels.Size > 0) Then
      AllLabels = Global.FavIni.sortList(AllLabels)
      For i = 0 To AllLabels.Size - 1
         Package = AllApps.Get(AllLabels.Get(i))
         Lable = PM.GetApplicationLabel(Package)
         Add = True
         If (Package.ToLowerCase = "esdaso.tools.appsfavorites") AND (Lable.ToLowerCase = "application-favorites") Then
            Global.cVersion = " v" & pm.GetVersionName(Package)
            Global.cTitle = Lable & Global.cVersion
            Activity.Title = Global.cTitle
            Add = False
         End If
         If (Add = True) Then
            bd = PM.GetApplicationIcon(Package)
            lstAllApps.AddTwoLinesAndBitmap(AllLabels.Get(i), Package, bd.Bitmap)
         End If
      Next
      DeleteItemFromAllApps
   End If
   ProgressDialogHide
   StopService(FavService)
End Sub
 
Last edited:

Amalkotey

Active Member
Licensed User
Longtime User
Problem gelöst / problem solved

@all:
So, now I know why. The code between ProgressDialogShow and ProgressDialogHide was processed quickly. I 'm now in the sub Activity_Create the code below

B4X:
Sub Activity_Create(FirstTime As Boolean)
   ProgressDialogShow("Installierte Apps werden ermittelt und Favoritenlise wird gelesen!")
   Global.Wait(3)

   ' code ...

   ProgressDialogHide
End Sub

and i implemented in my global codemodule, the following code:

B4X:
Sub Wait(Sekunden As Int)
   Dim Ti As Long
   Ti = DateTime.Now + (Sekunden * 1000)
   Do While DateTime.Now < Ti
      DoEvents
   Loop
End Sub

Thus it works. Thank you for your help.

Amalkotey
 
Upvote 0

Amalkotey

Active Member
Licensed User
Longtime User
No, works fine.
 
Upvote 0
Top