Many things have changed in B4X and also in the underlying platforms. I will try to list here all kinds of (old) features that have better alternatives.
B4X is backward compatible so these features still work. The recommendations are more relevant for new projects or when implementing new features.
More to come.
B4X is backward compatible so these features still work. The recommendations are more relevant for new projects or when implementing new features.
- (B4A) ListView -> xCustomListView:
ListView is difficult to work with and cannot be customized. It is also not cross platform.
- (B4i) TableView -> xCustomListView:
Same as above.
- CustomListView module -> xCustomListView library:
Using the module will break other libraries.
- Sub JobDone -> Wait For (j) JobDone:
[B4X] OkHttpUtils2 with Wait For
- Sub Smtp_MessageSent (and others) -> Wait For ...:
https://www.b4x.com/android/forum/threads/b4x-net-library-ftp-smtp-pop-with-wait-for.84821/#content
- DoEvents / Msgbox -> DoEvents deprecated and async dialogs (msgbox)
- All kinds of custom dialogs -> B4XDialogs: B4XDialogs are cross platform and are fully customizable:
[B4X] Share your B4XDialog + templates theming code
- File.DirDefaultExternal -> RuntimePermissions.GetSafeDirDefaultExternal
Truth is that you shouldn't use both of them and use XUI.DefaultFolder instead.
https://www.b4x.com/android/forum/threads/67689/#content
- File.DirRootExternal -> ContentChooser / SaveAs
https://www.b4x.com/android/forum/threads/132731/#content
- File.DirInternal / DirCache / DirLibrary / DirTemp / DirData / DirDefaultExternal / GetSafeDirDefaultExternal -> XUI.DefaultFolder
- Round2 -> NumberFormat, B4XFormatter:
Most usages of Round2 are to format numbers. Modifying the number is not the correct way.
- TextReader / TextWriter with network streams -> AsyncStreams:
Trying to implement network communication on the main thread will always result in bad results.
- TextReader / TextWriter -> File.ReadString / ReadList:
Two exceptions - non-UTF8 files or huge files (more relevant to B4J).
- Activities -> B4XPages:
This is a big change and it is the most important one. It is hard to explain how much simpler things are with B4XPages. The more complex the project the more important it is to use B4XPages. This is also true when building non-cross platform projects. [B4X] [B4XPages] What exactly does it solve?
- Platform specific API -> Cross platform API:
This is of course relevant when there is a cross platform API. Some developers have a misconception that the cross platform features have drawbacks compared to the platform specific API.- Node / Pane / Button / ... -> B4XView
- Canvas -> B4XCanvas
- All kinds of platform specific custom views -> cross platform custom views (such as XUI Views).
- EditText / TextField / TextArea / TextView -> B4XFloatTextField
- fx (and others) -> XUI
- MsgboxAsync / Msgbox2Async / (B4i) Msgbox -> XUI.MsgboxAsync / XUI.Msgbox2Async
- CallSubDelayed to signal a completion of a resumable sub -> As ResumableSub:
[B4X] Resumable subs that return values (ResumableSub)
- CallSubDelayed / CallSubPlus to do something a bit later -> Sleep(x):
There are many other useful usages for CallSubDelayed.
- Multiple layout variants -> anchors + designer script:
When Android was first released there were very few screen sizes. This is no longer the case. You should build flexible layouts that fill any screen size. It is easier to do with anchors + designer script. It is difficult to maintain multiple variants.
- Building the layout programmatically -> using the designer when possible:
If you are only developing with B4A then building the layout programmatically is a mistake but not a huge one.
B4J and B4i handle screen resizes differently and it is much more difficult to handle the changes programmatically (there is video tutorial about it).
Most custom views can only be added with the designer (there are workarounds that allow adding them programmatically).
It is very simple to copy and paste designer layouts between different platforms and projects.
- Multiline strings with concatenation -> smart strings:
[B4X] Smart String Literal
- (SQL) Cursor -> ResultSet:
ResultSet is cross platform and is also a bit simpler to use.
- ExecQuery (non-parameterized queries) -> ExecQuery2:
Making non-parameterized queries is really unacceptable. See point #5 for more information: https://www.b4x.com/android/forum/t...ommon-mistakes-and-other-tips.116651/#content
It is also true for ExecNonQuery.
- ExecQuerySingleResult when it is possible that there are no results -> ExecQuery2
This is a historic design mistake. Nulls and Strings don't go together. If there is a possibility that ExecQuerySingleResult will return no results (=Null) then don't use it and use ExecQuery2 instead.
- Downloading / making http requests with any other library or source other than OkHttpUtils2 (=iHttpUtils2) -> OkHttpUtils2
OkHttpUtils2 is very powerful and can be extended in many ways, without modifying the source. It is also very simple to use.
- Shared modules folder -> referenced modules
The shared modules feature was useful in the early days of B4X. With the introduction of referenced modules, there is no good reason to use it. Referenced modules cover the same use cases and more.
- VideoView -> ExoPlayer
ExoPlayer is much more powerful and more customizable.
- StartServiceAt / StartServiceAtExact -> StartReceiverAt / Exact
With a few exceptions, it is no longer possible to start services in the background.
More to come.
Last edited: