Android Question how to check if another specific app is installed

gz7tnn

Member
Licensed User
Longtime User
I have written 2 apps: 'MyAppA' and 'MyAppB'. MyAppB is an optional app and can be called from MyAppA if the user chooses. I have that aspect working but what I want to be able to do is disable the button in MyAppA if the user does not have MyAppB installed. I want that to happen when MyAppA is started.
I know the package name 'com.MyAppB' but have not found how to check if it is installed so that I can enable / disable the button in MyAppA.
I only need to know if MyAppB is installed.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I only need to know if MyAppB is installed.

Try this
B4X:
Dim pm As PackageManager
Dim apps As List
apps.Initialize
apps = pm.GetInstalledPackages
For i = 0 To apps.Size -1
    Dim apk As String = apps.Get(i)
    If apk.Contains("MyAppA") Then
        Log("MyAppA is installed. Package "&apps.Get(i))
    End If       
    If apk.Contains("MyAppB") Then
        Log("MyAppB is installed. Package "&apps.Get(i))
    End If       
Next
 
Upvote 0
Top