Manifest macros is a new feature coming in B4A v8.0.
The origin of this feature was to help with explicitly setting the theme. As explained here: https://www.b4x.com/android/forum/threads/version-safe-themes.87694/#content the default theme can be light or dark based on the device version.
This means that if you are not explicitly setting the theme then your app will look completely different on different devices and there is a large potential that it will not look as the you expect.
Setting it explicitly was not so simple.
With the new feature, the theme is set with:
In the future, when a new theme will be available then the macros will be updated accordingly.
This feature can also be useful in many other cases. For example instead of directly adding all firebase snippets which can add quite a mess to the manifest editor they can be added with:
Anyone, and especially library developers, can easily add new macros.
The macro file is a text file with the manifest editor code. It should be located inside a jar file (which is a regular zip file).
Example of FirebaseAds manifest in Eclipse:
If you are using SLC to build the library then you should put the macros in the "additional" folder.
Note that the extension should be b4x_excluded. This way the IDE knows not to include the macros in the APK.
You can add multiple macros inside your library.
Themes.jar which holds the theme macros looks like:
The origin of this feature was to help with explicitly setting the theme. As explained here: https://www.b4x.com/android/forum/threads/version-safe-themes.87694/#content the default theme can be light or dark based on the device version.
This means that if you are not explicitly setting the theme then your app will look completely different on different devices and there is a large potential that it will not look as the you expect.
Setting it explicitly was not so simple.
With the new feature, the theme is set with:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)
'Or
CreateResourceFromFile(Macro, Themes.DarkTheme) 'this line is added to the default manifest template
This feature can also be useful in many other cases. For example instead of directly adding all firebase snippets which can add quite a mess to the manifest editor they can be added with:
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
Anyone, and especially library developers, can easily add new macros.
The macro file is a text file with the manifest editor code. It should be located inside a jar file (which is a regular zip file).
Example of FirebaseAds manifest in Eclipse:
If you are using SLC to build the library then you should put the macros in the "additional" folder.
Note that the extension should be b4x_excluded. This way the IDE knows not to include the macros in the APK.
You can add multiple macros inside your library.
Themes.jar which holds the theme macros looks like:
Last edited: