Android Question Load Another App or Find it in App Store if It's Not Installed

Marroq Spoulinker

Member
Licensed User
Longtime User
Hello all,

I've been using this code in order to load other apps, and it works great for the most part.
B4X:
Dim pm As PackageManager
StartActivity(pm.GetApplicationIntent("your.other.app.package.name"))

Until you try to load an application that is not installed on the device, then it throws an error. At that point, I'd like to route the user to the Google Play Store to install the application, and I can easily get them to the Play Store app with this code:
B4X:
Dim pm As PackageManager
Try
StartActivity(pm.GetApplicationIntent("your.other.app.package.name"))
Catch 
   StartActivity(pm.GetApplicationIntent("com.android.vending"))
End Try

That works to open the Play Store app, but I have been unable to locate any instructions regarding how to use B4A to tell the Play Store to search for the desired app. I have found Java-specific instructions, but haven't been able to re-write those so that they will work in B4A.

Does anyone know how to do this?

Thank you!
 

JonPM

Well-Known Member
Licensed User
Longtime User
This is what I use
B4X:
Sub PlayStoreLink
   Dim fURI As String
   fURI = "market://details?id=com.b4a.example"
   Dim Market As Intent
   Market.Initialize(Market.ACTION_VIEW,fURI)
   StartActivity (Market)
End Sub
 
Upvote 0

Marroq Spoulinker

Member
Licensed User
Longtime User
This is what I use
B4X:
Sub PlayStoreLink
   Dim fURI As String
   fURI = "market://details?id=com.b4a.example"
   Dim Market As Intent
   Market.Initialize(Market.ACTION_VIEW,fURI)
   StartActivity (Market)
End Sub

Worked like a charm! Thank you so much JonPM.
 
Upvote 0
Top