Follow these steps to associate files, based on their extension, with your app. The user will be able to double click on a file and your app will be opened with the selected file.
Step 1: Make sure to use Java 11 with B4JPackager11 v1.10+.
Step 2: Add the code to handle the selected file.
Example:
Step 3: You need to modify InstallerScript-Template.iss file that is created when you run B4JPackager11.
The following code should be added:
It will associate files with .lst extension with your app. The file description will be My List Files.
The template file will be recreated every time that you run B4JPackager11. Make sure to copy it outside of the temp folder.
Step 1: Make sure to use Java 11 with B4JPackager11 v1.10+.
Step 2: Add the code to handle the selected file.
Example:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1")
MainForm.Show
If Args.Length > 0 Then
Try
If File.Exists(Args(0), "") Then 'don't assume that it is a valid path
ListView1.Items.AddAll(File.ReadList(Args(0), ""))
End If
Catch
Log(LastException)
End Try
End If
End Sub
Step 3: You need to modify InstallerScript-Template.iss file that is created when you run B4JPackager11.
The following code should be added:
B4X:
[Registry]
Root: HKCR; SubKey: .lst; ValueType: string; ValueData: My List Files; Flags: uninsdeletekey noerror; Tasks: ; Languages:
Root: HKCR; SubKey: My List Files; ValueType: string; ValueData: My List Files; Flags: uninsdeletekey noerror
Root: HKCR; SubKey: My List Files\Shell\Open\Command; ValueType: string; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletevalue noerror
Root: HKCR; Subkey: My List Files\DefaultIcon; ValueType: string; ValueData: {app}\{#MyAppExeName},0; Flags: uninsdeletevalue noerror
The template file will be recreated every time that you run B4JPackager11. Make sure to copy it outside of the temp folder.