Apple introduced push notification at a time when iOS apps didn't support multi-tasking. It was used as an intrusive notification system that allowed an app to communicate it had something important to tell you. Back then push messages would trigger a dialog box as it predated the pull down notification tray pioneered by Android.Read More
Proguard is one of the most disliked aspects of Android programming. Developers attack it left and right because there are so many nuances to it. That's a huge mistake, proguard is one of the most important tools in our development toolchain. It makes our apps slightly more secure, much smaller and even slightly faster. Codename One apps use proguard by default for Android. This is a huge benefit in our case because the limits related to obfuscation are very similar to the limits related to portability.Read More
WebSockets changed the way I do networking code. I combine them with WebServices to get the best of both worlds. But they still suffer in terms of reliability. With WebServices we have retries and a mostly transactional model. There is no permanent connection that should be re-established.Read More
The most secure password in the world is the one that doesn't exist. You remove the user from the equation with a completely random key. To be fair this has some drawbacks and a password still exists somewhere (in your phone/email) but generally this works rather well...Read More
I used to do a lot of enterprise consulting in the day and used to lecture a lot on J2EE (as it was known back then). A lot of that knowledge isn't as applicable even in the server side today, but the algorithms are surprisingly even applicable in mobile.
One of the algorithms I would explain a lot when teaching J2EE was the 2PC AKA Two Phase Commit.
I'm used to NetBeans but if I will ever switch it will be to IntelliJ/IDEA. It's a great IDE. I just need to rewire the muscle memory of my fingers for it. The Codename One plugin support on IntelliJ should be as good as the NetBeans support as the code is very similar. There are however a couple of pitfalls that a lot of people trip over which I'd like to discuss.Read More
A while back a question was asked on stack overflow How do you uninstall an extension using the CodenameOne Settings tool in NetBeans?Read More
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.Read More
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
Device only bugs are the worse. You need to go through a device build and reproduce/rinse/repeat. Thankfully these bugs are rare but sometimes they just hit you smack in the face. One such problem occurred when I was debugging a transition on Android related to a login form. I would move between a Form where I had the keyboard open to one where it was closed. This created a nasty effect where the keyboard folded leaving a black space and the transition played out about that black space.Read More
We've just added support for Travis CI in your Codename One projects. Travis can be set up to automatically test your project (i.e. run unit tests) on a variety of different platforms every time you commit changes to github.Read More
We have loads of demo Codename One apps hosted on Github, however cloning and running a project can be a little tricky because we generally don't publish the dependent jar files (e.g. CodenameOne.jar) in the Github repository. This helps keep the repository lean, but it adds some steps to the process of cloning and running the project.Read More
One of the less familiar features of Java is the mess of weak/soft/phantom references. This is a confusing mess and it's compounded by the fact that other languages (such as the reference counting Swift/Objective-C) have used these terms with a different meaning. To simplify this weak references in a garbage collected language allows you to keep a pointer (reference) to an object that won't force it to stay in RAM.Read More
I wrote two posts about the SMS activation process. In the first I discussed using the Twilio API via REST and in the second I discussed the native interfaces for SMS interception we can use in Android. Now it's time to put this all together and create a single API that's fluid. It should include the full UI process but be flexible enough to let you design your own experience.Read More
Last week I talked about using SMS to activate your application which is a pretty powerful way to verify a user account. I left a couple of things out though. One of those things is the ability to grab the incoming SMS automatically. This is only possible on Android but it's pretty cool for the users as it saves on the pain of typing the activation text.Read More
A very common question we get from developers is "how do I get the devices phone number". The answer is "you can't really and you shouldn't". To clarify, this is possible on Android but would require a scary set of permissions. It's blocked on iOS completely though so you'd need a different solution anyway...
If you look at apps like Uber, whatsapp etc. they all use SMS activation. They just ask you to type your number and activate your phone via SMS. Usually this SMS is sent from the server side but for simplicity lets discuss how this can be done entirely from your app.
I got a question the other day about a UI design for an upcoming Codename One app. In this UI the title floated on top of the content as the content scrolled past and tabs were a part of the title area in the style of material design.
Our tabs component predated material design by many years and wasn't designed for this sort of UI. When you scroll out of a tab it scrolls out. Using it for this sort of UI doesn't make much sense. The solution was to use a custom title area with two toggle radio buttons representing each tab with a line below to indicate the selected button.
On occasion I answer a question on stackoverflow, the discussion forum or elsewhere and I get a response of the form of: "this wasn't clear from the docs". We improved the docs but befitting a huge project run by engineers without a technical writer in sight this is a bit of a problem... The thing is that this is a problem you can fix regardless of your level in engineering or in English.Read More
I wrote in the past about importing a Codename One demo from github but I left the whole working with git as an open subject. Mostly because I considered it a bit out of scope for the discussion. I have a section in the free online course about the anatomy of a Codename One application which I completely forgot to upload until I wrote this!Read More
Text input is a very special case. Besides mixing the native and Java code we also need to deal with the appearance of the virtual keyboard which doesn't act consistently across platforms. This creates many complex edge cases that are just as problematic on native OS platforms as they are in Codename One.Read More
One of my favorite things about Mac OS is something subtle that took me a while to notice: it doesn't ask stupid questions. If you delete a file on a Mac it goes to the trashcan immediately, no question. Even though other OS's copied the trashcan concept they didn't embrace it in the same way, most of them still ask whether you are sure about this action even though the action is reversible.Read More
Image masking allows us to adapt an image which we acquired from an external source to fit our design e.g. if we want to show an image cropped to a circle we could apply a mask to it in order to get an intelligent crop. This is a very powerful tool as a designer can supply a hardcoded mask image and build some pretty complex shapes that include an alpha channel as well (making it superior to shape clipping).Read More
Tracking & logging errors is crucial for a stable application. There are several tools we offer in Codename One both in the seamless level (crash protection) and in the lower level inner workings of Codename One. I'll try to explain both and how they interact.Read More
I'm a bit conflicted about this tip. The
AutoCompleteTextField is a problematic class that is in dire need of a rewrite. When we created it we still didn't accept that lists "need to go". It also predated features like the
InteractionDialog which would have made this component much easier to use.
Using toggle buttons in touch interfaces is very intuitive for many use cases. We implement them via
CheckBox to indicate inclusive or exclusive selection. As a result I find myself using
RadioButton quite a lot and ran into an ommission that frankly should have been there from day 1.
The bootcamp is winding down and I'm finally back to our usual scheduled posts. I'd like to open with a common practice that isn't nearly documented enough: use the native main/EDT threads. Our EDT serves many purposes but one of it's biggest roles is portability. By having an EDT we get consistent behavior across platforms.Read More
We are on a mid-bootcamp break so the blog is back to life during this time (and there is so much to write!), more on that tomorrow but for now I'd like to write about fixing & tracking issues with the designer (resource editor) and the GUI builder.Read More
Bootcamp registration closed well and we are currently in the pre-course (more on that in another post) and already the Facebook group of the bootcamp is seeing decent activity. Being as busy as I am I thought I'd lift a question that was asked there to headline this post: "When shouldn't I use Codename One?".Read More
Before we go into the tip I'd like to start with an apology to all the people I didn't get back to. Earlier today I sent an email asking for help with the upcoming Codename One bootcamp. The anticipation and resulting email flood took me totally off-guard as I expected a couple of dozen responses in the best case scenario and got much more...
I started answering as fast as I could and getting back to people I already answered in the back and forth but quickly this became untenable and I'm seeing my backlog pile growing. Chen and others around here tried to help but I prefer to do this personally as I'd like the feedback to sink into my brain not as an afterthought as it is very valuable!
Integrating a native OS library isn't hard but it sometimes requires some juggling. Most instructions target developers working with xcode or Android Studio & you need to twist your head around them. In Android the steps for integration in most modern libraries include a gradle dependency.Read More
I recently had to debug some code on Android Studio and was reminded how awful that IDE really is. IntelliJ is a pretty good IDE but Android Studio is remarkably slow even for trivial projects... One of the things that make it slow (besides RAM usage) is the approach of downloading everything it needs dynamically.Read More
Tabs component isn't our first attempt at the the multi-tab UI and as such we made a lot of changes to the logic to facilitate a level of flexibility that can answer most use cases e.g. Tabs that can be closed with an X on the top right section or span multiple rows.
On occasion developers ask us for cn1lib dependencies, e.g. allowing one cn1lib to use functionality in another cn1lib. This isn't something we rolled into the cn1lib infrastructure because we strongly believe in simplicity. Dependency management solutions become fragile once nesting sets in and often mask over-engineering which is really dangerous for a tool that depends on small footprint.Read More
Opening a demo or sample code from GIT is relatively easy if you are an experienced Codename One developer but for a lot of newer developers for whom samples are often more crucial this can be challenging. One of our solutions was placing the demos in the Codename One new project menu but that's probably not enough.Read More
One of the most painful aspects in any mobile app is input, besides the difficulty of viewing the details on a tiny cramped screen the input via the virtual keyboard is nowhere near the input comfort of a full fledged computer or even a tablet.Read More
A frequent complaint we get is the lack of a search feature on the site and we get that. It's frustrating to us too. We'd like to add it but are still looking at the "right way" to do it which I'll discuss at more length below but for now I'd like to discuss a couple of relatively simple workarounds.Read More
In the first betas of Codename One we had a lot of bugs related to 2D arrays due to XMLVM. We no longer use XMLVM but the recommendation to avoid 2D arrays remains. We still use them in some occasions e.g. in the creation of a
DefaultTableModel but the implementation discards them in favor of an
One of the nice things in mobile development vs. desktop is the fact that updates are seamless. We supposedly don't need to worry about them and most newer OS's turn them on by default. This keeps are users with the latest version which is important, e.g. if we fixed a crucial bug or added a new monetization option...Read More
I deal with a lot of questions every day and unfortunately most of them are phrased in a way that forces me to guess. There are some guidelines on how to ask a question but I think they are mostly pretty bad. Asking a question "correctly" helps you tremendously both in getting a correct answer faster and also in solving your own question. Following these three rules will significantly improve your questionsRead More
One of the most frustrating things that can happen to developers is when you manage to reproduce a rare bug but you are not in the debugger when you did that. My kingdom for a stack trace...
But this is also pretty frustrating when you work on a tool like Codename One's designer or GUIBuilder and they suddenly freeze with no visible error. How do you provide a viable bug report for that?
Some designs don't work well in landscape/portrait mode and we need to adapt them to fit the orientation of the device e.g. when we have a large graphic element (icon etc.) on top/below and we no longer have room for that element.Read More
Codename One's resource files contain a lot of details but it's sometimes hard to add elements into the resource file automatically. Recently I wanted to add a better way to add images directly in the new GUI builder. I considered several options and eventually decided to operate the designer tool automatically to do the "heavy lifting".Read More
We previously discussed the problems with List and somewhat neglected
ComboBox which is a subclass of
ComboBox has the dubious "honor" of deriving most of the problems
List has and adding a slew of its own problems such as two separate renderers, different behaviors between OS's etc.
Google Play Services is a proprietary set of tools that Google licenses to vendors under limited conditions. In recent years more and more features go into Google Play Services making it harder to build an app without it.Read More
We've discussed codapps.io before, it's a MOOC (online course) that allows you to learn Java programming and uses mobile/Codename One as its vehicle. Our current documentation and tutorials can be quite intimidating to a person who is a complete Java newbie so this course is quite helpful in bridging that gap.Read More
The two key factors to improve any product are: get help from your biggest fans and learn from your detractors. Obviously there is a lot of nuance to that wide reaching advice...
Rating widgets embody this advice. They prompt a user for a rating. If it's good we ask him to review the app in the appstore and thus bring more users. If it's bad we ask him to tell us why!
Every now and again developers ask us how we do the graphics for our posts/promotions and up until recently the answer was "photoshop". While knowing photoshop is still very worthwhile we still like these 3 tools that provide great shortcuts to creating both screenshots and art.Read More
You probably recently received the “Next Steps from the Parse Team” newsletter in your inbox in which you were urged to take immediate action as it pertains to migrating your Parse.com hosted apps.Read More
When we initially designed the cn1lib file format we looked at jar files as a starting point. We wanted a way to distribute binary libraries that support the native code access, restrictions and ideally code completion.Read More
When I first read the announcement that Parse.com would shut down on January 28th 2017, I went from disbelief (it’s probably an early April fool’s joke) to rage (how could they do that?!) to sadness (oh no! it was a great service) and finally to utter confusion (where do I go from here and what do I do with my apps - parse4cn1, two MVPs for clients and an upcoming rewrite of Medex for which I was planning to use Parse.com as backend?). A few months down the line, a lot has happened such as the release of the open source Parse Server (yay!) and subsequently the Parse Dashboard. However, I still had to decide what do with my apps and I guess you have to as well.Read More
One of my pet peeves when we switched to github was that email notifications never worked for me. For most repositories I had to setup my own account just to get emails. I'm guessing that this is a common problem for those of us who are used to emails notifying us of changes.Read More
Sticky headers was one of the first big requests we said no to. Back in the day a lot of people asked for it but we always shot it down because it was too hard to implement on top of our Swing inspired lists. This predated our Container improvement,
The NetBeans plugins.netbeans.org site has been down for another weekend and has been down again today. This isn't ideal as we like the convenience the official plugin center affords in our update process. However, this blocks installs and updates of our plugin most of which originate from NetBeans.Read More
For years we treated support with a "we'll meet our developers where they are" attitude which is problematic now that we have more than 6 free support channels!
Notice that we didn't include the email/phone support for pro/enterprise users in the list of 6 channels...
In our original Java 8 support announcement post we specifically mentioned the lack of streams but completely missed the fact that default/static native interfaces didn't work. This is now fixed thanks to an alert community member who pointed that out.Read More
While multi-image's go a long way in making your app scalable to various devices, scalable images can be even more convenient. The SVG standard never took off though, its too complex to support in an efficient way on the devices and so its relegated to web applications and even those don't make heavy use of it due to its complexity.
However, icon fonts have gained a lot of popularity in recent years and we used them in the past in Codename One e.g. in the photo demo.
Our build servers are really fast, even if your laptop is relatively slow our iOS build servers are powerful machines equipped with fast SSD's and they generate a full clean build of a typical app (with screenshots etc.) in a couple of minutes!
So the real source of delay when building an app is size, it both slows the build but most of all it slows your upload process (upload is typically much slower than download). Reducing the size of your app will make it faster in runtime as well, e.g. if you have too many redundant resources you might be running into too many GC cycles slowing down execution. In this post we provide some tips to shrink your app size.
With the release of 3.0 we were overwhelmed with a lot of last minute features and improvements. It seems that we neglected to mention a lot of features that made it into the final 3.0 product.
One of the nicest new features is a set of new flat themes with various colors in the designer and the project wizard. We found that a lot of developers prefer themes with more control over the look, themes that look more similar across platform yet have a more modern "flat" feel.