run an application

sirjo66

Well-Known Member
Licensed User
Longtime User
Hello,
from my program I need to run another application,
so I have found this code:

B4X:
Sub YourButton_Click
  Try
    Dim Intent1 As Intent
    Dim pm as PackageManager
    Intent1 = pm.GetApplicationIntent ("com.package.tolaunch")
    StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try
End Sub

Ok, but program name that I need to lunch is "ilMeteo", but how can I found "com.package.tolaunch" of this program ???

Thanks
Sergio
 

derez

Expert
Licensed User
Longtime User
Hello,
from my program I need to run another application,
so I have found this code:

B4X:
Sub YourButton_Click
  Try
    Dim Intent1 As Intent
    Dim pm as PackageManager
    Intent1 = pm.GetApplicationIntent ("com.package.tolaunch")
    StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try
End Sub

Ok, but program name that I need to lunch is "ilMeteo", but how can I found "com.package.tolaunch" of this program ???

Thanks
Sergio
Look at android/data directory in the device , you'll see all the installed applications group names.
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Look at android/data directory in the device , you'll see all the installed applications group names.

No, in this directory there aren't all the installed applications :-(

I want to run 2 program, "ilMeteo" and "AirDroid" and I don't find any

Sergio
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
To run applications you MUST know the package names:

AirDrod: com.sand.airdroid
ilMeteo : com.ilmeteo.android.ilmeteo

For example, if you want to run AirDroid you do this:
B4X:
Sub YourButton_Click
 
Try
 
    Dim Intent1 As Intent
    Dim pm as PackageManager
    Intent1 = pm.GetApplicationIntent("com.sand.airdroid")
 
    StartActivity (Intent1)
 
Catch
 
    ToastMessageShow("Failed to launch app! Is it installed?", True)
 
End Try
 
End Sub
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Hi Sergio

Try use this strategy as below,if you want to run ilMeteo

B4X:
Dim i as Intent
Dim Pm As PackageManager 
Dim Packages As List
Dim st As String
        Dim k As Int
Packages = Pm.GetInstalledPackages

For k = 0 To Packages.size - 1
        st=Packages.Get(k)
        If st.Contains("ilMeteo") =True Then
                i=Pm.GetApplicationIntent(st)
                        If i.IsInitialized Then   
        StartActivity(i)
           Exit
    End If
    End If
Next
 
Upvote 0
Top