Basic4android v2.50 includes a new method for handling project and modules settings.
These settings are now set in the code itself. The menu items were removed.
The attributes syntax is simple. The hash sign (#) followed by the attribute name, a colon and the value.
Some attributes can appear more than once in the same module.
Different modules (activities, services, ...) support different attributes. The IDE will show a list with the supported attributes when you press on the hash key.
The project related attributes should be placed in the main activity.
Note that the #Region / #End Region directives are not required.
The attributes will be added automatically to existing projects when they are first loaded with the new version.
The purpose of this feature is to make it simpler to support new features that require advanced settings.
Project attributes (should be placed in the main activity)
Activity attributes
Service attributes
All modules support the following attributes:
Custom Build Actions
The build process is made of a number of steps. You can add additional steps that will run as part of the build process. For example you can run a batch file that will copy the latest resource files from some folder before the files are packed.
Another example. You can use this code to mark all files under res folder as read-only (and prevent the compiler from deleting them):
Note that you can add any number of build actions.
CustomBuildAction should be added to the main activity.
The running folder is set to the program objects folder.
The syntax is:
<step id>, <program to run>, <program arguments>
step id can be one of the following:
1 - Before the compiler cleans the objects folder (it happens after the code is parsed).
2 - Before R.java file is generated.
3 - Before the package is signed (the APK file at this point is: bin\temp.ap_).
4 - Before the APK is installed.
5 - After the APK is installed.
6 (new in v5.01) - After Java compilation.
These settings are now set in the code itself. The menu items were removed.
The attributes syntax is simple. The hash sign (#) followed by the attribute name, a colon and the value.
Some attributes can appear more than once in the same module.
Different modules (activities, services, ...) support different attributes. The IDE will show a list with the supported attributes when you press on the hash key.
The project related attributes should be placed in the main activity.
Note that the #Region / #End Region directives are not required.
The attributes will be added automatically to existing projects when they are first loaded with the new version.
The purpose of this feature is to make it simpler to support new features that require advanced settings.
Project attributes (should be placed in the main activity)
- CanInstallToExternalStorage - Whether the application can be installed to the external storage. Values: True or False
- SupportedOrientations - Sets the supported orientations. Values (case is important): unspecified, portrait or landscape (other possible values)
- ApplicationLabel - The application label that will appear in the applications list (string)
- VersionName - Version name (string)
- VersionCode - Version code. Must be an integer
- Library compilation attributes. Covered in the library compilation tutorial
- CustomBuildAction - See the Custom Build Actions section in this tutorial.
- AdditionalRes - Specifies a folder with resource files. These resource files will be added to the APK. This attribute also accepts an optional parameter, the package name of an Android library project. This is required when wrapping a library that includes resource files. See this example: jfeinstein10 SlidingMenu libraryYou can use this attribute multiple times.
- DebuggerForceFullDeployment - Forces the rapid debugger to redeploy the complete project every compilation. This can be useful if you see slow performance after modify the code. It will disable the quick redeployment feature of the rapid debugger.
Values: True or False.
- DebuggerForceStandardAssets - Disables the virtual assets feature of the rapid debugger. By default the rapid debugger doesn't use the standard assets folder. This allows the debugger to only redeploy updated files. Values: True or False.
- ExcludeClasses - Can be used to strip library classes during compilation: https://www.b4x.com/android/forum/threads/new-feature-three-birds-with-one-stone.63127/
Activity attributes
- FullScreen - Whether to show the top bar. Values: True or False
- IncludeTitle- Whether to show the title. Values: True or False
Service attributes
- StartAtBoot - Whether this service should start automatically after boot. Values: True or False
- StartCommandReturnValue - (advanced) Sets the value that will be returned from onStartCommand. The default value is android.app.Service.START_NOT_STICKY. See this link for the possible values.
All modules support the following attributes:
ExcludeFromDebugger- Whether to exclude this module from the debugger. Debug information will not be added to this module. Values: True or False
This attribute is only relevant to the legacy debugger.
- IgnoreWarnings - A list of warnings numbers that will be ignored in this module.
Custom Build Actions
The build process is made of a number of steps. You can add additional steps that will run as part of the build process. For example you can run a batch file that will copy the latest resource files from some folder before the files are packed.
Another example. You can use this code to mark all files under res folder as read-only (and prevent the compiler from deleting them):
B4X:
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s
Note that you can add any number of build actions.
CustomBuildAction should be added to the main activity.
The running folder is set to the program objects folder.
The syntax is:
<step id>, <program to run>, <program arguments>
step id can be one of the following:
1 - Before the compiler cleans the objects folder (it happens after the code is parsed).
2 - Before R.java file is generated.
3 - Before the package is signed (the APK file at this point is: bin\temp.ap_).
4 - Before the APK is installed.
5 - After the APK is installed.
6 (new in v5.01) - After Java compilation.
Last edited: