Latest posts from Codename One.
Blog

Codefreeze for Codename One 4.0 – Taxi
Codename One 4.0 (Taxi) will launch next week, to keep the code stable we are entering a week long code freeze. Please update your plugin installs frequently and report bugs immediately so we will have a stable release! We’ve added a lot of new features to 4.0 but the big things are pretty disruptive: Xcode 9.2 switch Update Framework Because both of these changes have many subtle implications we are relying on feedback from you on what’s working and what isn’t. If you run into any issue please file the issue ASAP so we can move quickly and update the release if necessary. ...

Map Layout Update
__ The information in this blog post is slighly out of date. Check out the newer blog post that covers positioning components on the map. A while back I introduced a MapLayout class as a tip and discussed the usage of this class. Since that introduction we ran into some scale issues as the layout misbehaved when a lot of elements were added to it. The crux of the issue is in the native map API which runs on the OS native thread and the Codename One API which needs immediate responses for layout. ...

New Default Code
This is new behavior that went in without fanfare. If you created a new hello world app you might have noticed this. We changed the default boilerplate for Codename One and made it more representative of what you’d want to see in a hello world app. The entire change to the default generated app is within the init method: public void init(Object context) { // use two network threads instead of one updateNetworkThreadCount(2); __**(1)** theme = UIManager.initFirstTheme("/theme"); // Enable Toolbar on all Forms by default Toolbar.setGlobalToolbar(true); // Pro only feature Log.bindCrashProtection(true); addNetworkErrorListener(err -> { __**(2)** // prevent the event from propagating err.consume(); if(err.getError() != null) { Log.e(err.getError()); } Log.sendLogAsync(); Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null); }); } __1 By default networking in Codename One runs on one network thread for consistency. Two threads make more sense from a performance standpoint. We wanted to make this easily configurable and it should be easy in the init() method __2 Handling network errors in a generic way is probably one of the hardest things to grasp. So many developers are still stuck with the default error handling code… With that in mind we added a bit of boilerplate to handle network errors in a way that makes sense and should be easily customizable I had some thoughts about removing this boilerplate and packaging it in a class. But then I thought again. ...

TIP: Include Source with Android Studio 3.0
I covered the include source feature extensively. For the most part it’s the simplest way to debug an application directly on the device. When I made that video the current version of Android Studio and Gradle were much older. We still use API version 23 on the build servers to keep everything compatible but you might want to use a newer version of the IDE. In that case you can use the newer version 3.0+ of Android Studio but you will need to make a few updates to the process. ...

Updated 4.0 Release Date
Last week I mentioned we are considering postponing the release planned for next week. We eventually did just that and the release is now scheduled for the 20th with code freeze on the 13th. So far we didn’t change future release dates but there might be a cascading effect. As I explained before, this is an inevitable result of the migration to xcode 9.2 which is something we need to stabilize before the release. ...

Tune Performance, Profile on Devices in Latest Academy Update
I promised 2 new course modules for February and just published the second one. In case you don’t recall I discussed the first one here and it covered building Codename One applications from the open source code. This new module goes through seven lessons that cover everything you need to know when building a performant app. It covers everything from generic performance tips/analysis all the way to profiling and a case study. You can check out the full module in the Deep Dive into Mobile Programming course in the academy. ...

TIP: Streams are Observable in Codename One
We got a pull request the other day that reminded me of some hidden functionality in Codename One that most developers aren’t aware of: observable input streams. By default Codename One API’s try to return BufferedInputStream and BufferedOutputStream instances from our internal API’s. Those classes aren’t the typical java.io versions but rather ones from the com.codename1.io package. That API allows us to add functionality into the streams without breaking the Java compatibility or specs. One such feature is setProgressListener(IOProgressListener). This is probably better explained with a simple sample: ...

Preferences Binding and getAndSet()
I added support for binding a property object to Preferences a while back and just didn’t have the time to blog about it. I didn’t consider it too crucial as the functionality is very simple to figure out, the only difficult part is knowledge of the features existence. Some objects make sense as global objects, we can just use the Preferences API to store that data directly but then we don’t have the type safety that property objects bring to the table. That’s where the binding of property objects to preferences makes sense. E.g. say we have a global Settings property object we can just bind it to preferences using: ...

Use our Open Source Code to Build Codename One Offline
I promised 2 new course modules for February and just published the first one. It covers the process of building a Codename One app from the Codename One source code. The whole process is done without using the Codename One plugin or build servers. It uses only open source project code to deliver iOS/Android & desktop binaries! You can check out the full module in the Deep Dive into Mobile Programming course in the academy. ...

Xcode 9.2 on by Default this Friday
A few weeks ago I announced the xcode 9.2 mode and was rather happy that we can take our time with the migration. Unfortunately, that wasn’t meant to be. Apple will require all new submissions to use xcode 9 within the next few months so it makes no sense to keep 7.3 as the default. This weekend we will flip the switch and builds will default to 9.2. It’s earlier than we wanted to but it’s crucial that Codename One 4.0 will work well with xcode 9.2 otherwise developers won’t be able to use versioned build halfway through the 4.0 cycle. ...

New Update Framework
When it comes to big changes this is pretty huge but surprisingly “subtle”. This weekend we’ll release a new plugin update that will completely replace the update process of Codename One and a week after that we will start nagging you to update your plugin so we can all be on the same page. This is a HUGE change as we didn’t change anything about the update process since 2012. But the cool thing about it is that you might not notice it… ...

New Async Java-Javascript Interop API
We recently introduced a new API for interacting with Javascript in Codename One. This new API is part of the BrowserComponent class, and effectively replaces the com.codename1.javascript package, which is now deprecated. So what was wrong with the old API? The old API provided a synchronous wrapper around an inherently asynchronous process, and made extensive use of invokeAndBlock() underneath the covers. This resulted in a very nice API with high-level abstractions that played nicely with a synchronous programming model, but it came with a price-tag in terms of performance, complexity, and predictability. Let’s take a simple example, getting a reference to the “window” object: ...