Android Question launch Ibochs with command line options


Licensed User
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


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
End Sub

#Region LaunchOtherApp 'I got this code off - 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.
'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.
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
If st.ToLowerCase.Contains(packageName.ToLowerCase) = True Then
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
Inte.Initialize(Inte.ACTION_MAIN, "")
End If
If Inte.IsInitialized Then StartActivity(Inte)
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)
If i=1 Then FoundFirstActivityName=cn
Return FoundFirstActivityName
End Sub
#End Region LaunchOtherApp
Last edited:


New Member
Hi Boys (and a few girls)

I am JoAnna, 'Scottie' 's sister. I also use B4A. Actually I'm the one who told him about it. :)
I would like to weigh in on his question with a question because I know what he's trying to do.
He can't access app data folders anymore. Thanks Google :(

We all understand that Android is blocking file access to installed apps data folders. Pro's and Con's to that.
Now, I could be wrong here. Scott, you can correct me. I think he is only using core, phone, runtimepermissions libraries.
Scott, did you upgrade to B4A v11?

Example: /storage/emulated/0/Android/
these folders are now protected. but.. File managers like X-plore and Es File Explorer (we both use X-plore)
can access these folders just fine. I've even tried an older version of X-plore and ES and they both can
still access Android 11 app folders.
So why can't we in B4A? Or maybe we can? Not talking about apps to go on Google Play. I'm talking about
private/custom apps we make with B4A.
I know he tried setting targetSdkVersion="28" all the way down to 4 and still didn't work.
Maybe use an older version of B4A? or older Libraries?
There's got to be a way... for B4A ha ha



New Member
I believe I got it to work.
remember no wilcards and exact case

If File.Exists(File.DirRootExternal & "/Android/data/lb.myapp.lbochs/files","file.txt") =true then
end if

i can write to there too
file.writestring(File.DirRootExternal & "/Android/data/lb.myapp.lbochs/files","file.txt","JoAnna is soo cute")

If you come for dinner tonight, I'll teach you how to program. ha ha



Licensed User
Good burn... ouch Haaa Haa Haaa
Just like your steak last night :)

but that wont work in Android 11. File.Exists(..) does work but that's about it.
Android 11 blocks access to /Android/data/...

I've even tried: Manage External Storage - access internal external storage >= SDK 30
Manage External Storage
file.writestring(..) will not work.
file.copy(..) will not work either.

EditText1.Text= File.ReadString(File.DirRootExternal & "/Android/data/lb.myapp.lbochs/files","lbochs.bxrc")
didn't work either

that's why I was wanting to figure out how to pass command line parameters to the app.