Hi there,
I would like to launch the lbochs emulator app with the command line "-f win31.bxrc" <- that is a configuration file
lbochs says it's accepts command line options if launcher can do it
Question is how to pass command line options via B4A when launching the app?
here's the code i'm trying.. it will launch the app fine, but no command line options
-Scott
Private Sub Button3_Click
Handle_Load_App("lb.myapp.lbochs") 'i need to add the "-f win31.bxrc"
End Sub
Sub Handle_Load_App(MyApp As String) 'run apps on server
ToastMessageShow(MyApp,True)
RunAppByPackage(MyApp,True)
End Sub
#Region LaunchOtherApp 'I got this code off b4x.com - Thanks
'Usage: Launch another app, inside of your app meaning that when you click on recent apps button
'will show your app name and not the other app that you are launching,
'or as external app meaning that when you press the recent apps button will show your app name and
'the app that you are launching.
'Parameters:
'packageName as String = this is the package name of the app that you want to launch, could be the partial package name too.
'LaunchUsingAlternativeMode as boolean = True for Launch inside of your app, False as external.
'Example:
'<code>
'RunAppByPackage("package.name.that.you.wantToLaunch",False)
'RunAppByPackage("com.sec.android.app.clockpackage/.AlarmActivity",True)
'RunAppByPackage("com.sec.android.app",True)
'RunAppByPackage("com.android.settings/.wifi.WifiPickerActivity",True)
'</code>
Sub RunAppByPackage(packageName As String, LaunchUsingAlternativeMode As Boolean)
Dim Pm As PackageManager
Dim Inte As Intent
Dim st As String = packageName
If packageName.IndexOf("/")=-1 Then
Dim Packages As List
Packages = Pm.GetInstalledPackages
For i = 0 To Packages.size - 1
st=Packages.Get(i)
If st.ToLowerCase.Contains(packageName.ToLowerCase) = True Then
Inte=Pm.GetApplicationIntent(st)
Log(st)
If Not(Inte.IsInitialized) Or LaunchUsingAlternativeMode Then
Inte.Initialize(Inte.ACTION_MAIN, "")
Dim packageNamePlusActivityName As String = GetIntentActivityFromAPackage(st)
If packageNamePlusActivityName.Length>0 Then Inte.SetComponent(packageNamePlusActivityName)
End If
Exit '<---Will pick the first package on the list
End If
Next
Else
Inte.Initialize(Inte.ACTION_MAIN, "")
Inte.SetComponent(st)
End If
Try
If Inte.IsInitialized Then StartActivity(Inte)
Catch
Log("failed launching "&st)
End Try
End Sub
'Usage : Return the first activity that found with the package name
Sub GetIntentActivityFromAPackage(packageName As String) As String
Dim i As Int =0
Dim pm As PackageManager
Dim FoundFirstActivityName As String = ""
Dim Intent1 As Intent =pm.GetApplicationIntent(packageName)
For Each cn As String In pm.QueryIntentActivities(Intent1)
Log(cn)
i=i+1
If i=1 Then FoundFirstActivityName=cn
Next
Return FoundFirstActivityName
End Sub
#End Region LaunchOtherApp
I would like to launch the lbochs emulator app with the command line "-f win31.bxrc" <- that is a configuration file
lbochs says it's accepts command line options if launcher can do it
Question is how to pass command line options via B4A when launching the app?
here's the code i'm trying.. it will launch the app fine, but no command line options
-Scott
Private Sub Button3_Click
Handle_Load_App("lb.myapp.lbochs") 'i need to add the "-f win31.bxrc"
End Sub
Sub Handle_Load_App(MyApp As String) 'run apps on server
ToastMessageShow(MyApp,True)
RunAppByPackage(MyApp,True)
End Sub
#Region LaunchOtherApp 'I got this code off b4x.com - Thanks
'Usage: Launch another app, inside of your app meaning that when you click on recent apps button
'will show your app name and not the other app that you are launching,
'or as external app meaning that when you press the recent apps button will show your app name and
'the app that you are launching.
'Parameters:
'packageName as String = this is the package name of the app that you want to launch, could be the partial package name too.
'LaunchUsingAlternativeMode as boolean = True for Launch inside of your app, False as external.
'Example:
'<code>
'RunAppByPackage("package.name.that.you.wantToLaunch",False)
'RunAppByPackage("com.sec.android.app.clockpackage/.AlarmActivity",True)
'RunAppByPackage("com.sec.android.app",True)
'RunAppByPackage("com.android.settings/.wifi.WifiPickerActivity",True)
'</code>
Sub RunAppByPackage(packageName As String, LaunchUsingAlternativeMode As Boolean)
Dim Pm As PackageManager
Dim Inte As Intent
Dim st As String = packageName
If packageName.IndexOf("/")=-1 Then
Dim Packages As List
Packages = Pm.GetInstalledPackages
For i = 0 To Packages.size - 1
st=Packages.Get(i)
If st.ToLowerCase.Contains(packageName.ToLowerCase) = True Then
Inte=Pm.GetApplicationIntent(st)
Log(st)
If Not(Inte.IsInitialized) Or LaunchUsingAlternativeMode Then
Inte.Initialize(Inte.ACTION_MAIN, "")
Dim packageNamePlusActivityName As String = GetIntentActivityFromAPackage(st)
If packageNamePlusActivityName.Length>0 Then Inte.SetComponent(packageNamePlusActivityName)
End If
Exit '<---Will pick the first package on the list
End If
Next
Else
Inte.Initialize(Inte.ACTION_MAIN, "")
Inte.SetComponent(st)
End If
Try
If Inte.IsInitialized Then StartActivity(Inte)
Catch
Log("failed launching "&st)
End Try
End Sub
'Usage : Return the first activity that found with the package name
Sub GetIntentActivityFromAPackage(packageName As String) As String
Dim i As Int =0
Dim pm As PackageManager
Dim FoundFirstActivityName As String = ""
Dim Intent1 As Intent =pm.GetApplicationIntent(packageName)
For Each cn As String In pm.QueryIntentActivities(Intent1)
Log(cn)
i=i+1
If i=1 Then FoundFirstActivityName=cn
Next
Return FoundFirstActivityName
End Sub
#End Region LaunchOtherApp
Last edited: