Android Question get all installed packages "FACEBOOK"

Fadi-l

Member
Hi...

I'm trying to get all apps' packages that installed in the device
I use this code

B4X:
Dim pm As PackageManager
Dim list As List = pm.GetInstalledPackages
Dim package  As String = list.Get(i)

but some apps that already installed doesn't bring it, like Facebook

what should I do ?

Thank you ...
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
i see her when i do pm.GetInstalledPackages
 

Attachments

  • capture.png
    4.6 KB · Views: 224
Upvote 0

Fadi-l

Member
Thank you for your reply

I tried again and found this message
error: Exception : Package manager has died
maybe for that reason many apps didn't show

I'm collecting the apps using another Thread, for avoiding app freezing

B4X:
Sub UpdateAppsList
    If Thread_Get_Data.IsInitialized = False Then
        Thread_Get_Data.Initialise("Thread_Get_Data")
    End If
    
    If Lock_apps.IsInitialized = False Then
        Lock_apps.Initialize(True)
    End If
    
    Dim msg As String = "Loading Apps ..."
    ProgressDialogShow2(msg,False)
    
    Dim args(0) As Object
    Thread_Get_Data.Join(0)
    Thread_Get_Data.Name = "Thread_1"
    Thread_Get_Data.Start(Me, "Thread_Load_Data", args)
End Sub

Sub Thread_Load_Data
    Lock_apps.Lock
    Dim list As List = pm.GetInstalledPackages
    Do Until Lock_apps.LockState = False       
        For i = 0 To list.Size-1
            Dim package  As String = list.Get(i)
            Dim title As String = pm.GetApplicationLabel(package)
        Next
        Lock_apps.Unlock
    Loop
End Sub

Sub Thread_Get_Data_Ended(fail As Boolean, error As String) 'An error or Exception has occurred in the Thread
    If fail = False Then
        Log("error: " & error)
        ToastMessageShow("error: " & error, False)
        ProgressDialogHide
        Return
    End If

    ProgressDialogHide
    
    Dim msg As String = "Apps list has been updated"
    ToastMessageShow(msg, False)
End Sub
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
who told you that you had to use threads for this?
 
Upvote 0

Fadi-l

Member
hi drafottjr
that's not the full code..

I have a lot of apps in my device, so when load the packages and gets their info and images and create a panel for each one, it's take a long time and the app just freezing for a period of time,
so I solved this problem by using threads.

and finally I found the problem
each app I get the path and the size, just this package "com.facebook.katana" (FACEBOOK) , when I try to get it size,
it will stop and gives me "error: Exception : Package manager has died"

I solved the problem , Thank you all
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…