Fork us on GitHub

Questions of the Week X

Size, Glasspane, Parse, Websockets, Swipe, MultiButtons, ZipAlign, Native, Watches, Facebook & more
Post Image

Questions of the Week X

This has been a tremendous week with a lot of news & next week will be even more hectic!
Next week we will turn on the new iOS build servers by default which means a huge change is coming the biggest is probably http connection problems but I’m sure we’ll run into quite a few other issues…​

Please let us know immediately as you run into issues…​

Onwards to the activity on stackoverflow this week:

IS there a way to obtain device screen width and height

This was marked as a duplicate despite being very explicitly defined as a Codename One question. I think the biggest takeaway is don’t call anything "urgent" on stackoverflow…​

Is glassPane painting model broken?

Surprisingly the answer is yes, we broke something when fixing issue 1680 a while back and this should be fixed in todays release.

Searching for a good parse4cn11 alternative

I’m curious about that myself, I’d like to actually keep using parse4cn1 but map it to a different 3rd party server for simpler migration.

WebSocket with multiple ClientEndpoints and binary messages

Turns out this was a server issue related to the websocket implementation there. I think we need to have better websocket demos/tutorials as this is picking up as a standard and is really appropriate for Codename One…​

Adding multiple multibuttons to a form after querying a webservice

When you change a form after it is shown you need to revalidate…​
Another common mistake is to change the form from a network thread.

Swipe the screens for next pages

Tabs was designed with exactly that use case in mind…​

App unfortunately stopped form codenameone with paypal integration

When you get that error it means you got an exception that you didn’t catch in the native code.

Initialising subcomponents of a GUI form

We are in the process of moving to the new GUI builder which is mostly delay due to lack of documentation. We hope to release docs for this in the coming weeks.

Error in Native Interface

It’s often hard to tell what the error is without a call stack or more information.

Log in with Facebook using Webview component

This was a rather long thread that stretched into several related questions, it turns out that the problem originates from a slightly older Facebook SDK using an approach Apple suddenly decided to reject.

Facebook updated the SDK and we already integrated the new SDK to support the new bitcode build mode. However, to preserve compatibility we limited the SDK only for that new version. So starting with todays release all builds are using the new Facebook SDK.

Codename one Native IOS implementation error: .h file not found

This is related to the previous question which was eventually resolved by us but it might be interesting to developers working with native SDKs.

How to include using Smartwatches in an app written with Codename One?

We don’t support smartwatches at this time although you should be able to add support for them using native code. We think supporting smartwatches/TV’s should be pretty easy but both depend on demand we get from developers which is currently non-existent. This might change overnight though.

React on Tree expansion or collapse

Tree is very customizeable, I would also recommend checking out the new Accordion component which we will cover more in depth in a post sometime next week…​

Change color of checkbox in theme

The color of checkboxes in some themes is derived from images, we are trying to slowly de-emphasize that in favor of the builtin material design icon font which should make color inheritance much easier.

Can not access com.codename1.impl.android.AndroidNativeUtil From nativeInterface

You still need import statements when building the native code for an application…​

Why the decreasing the png/jpg quality factor in ImageIO.save() does not decrease the output image file size?

It’s nice that people notice small things like that about the API, it was indeed unclear from the JavaDocs that this was acceptable by design.

Disable pull-to-refresh on InfiniteContainer in codenameone

That’s an easy answer, you can’t. For that we have the InfiniteScrollAdapter which is roughly of the same complexity level as the InfiniteContainer.

How to prevent west and East elements from overlapping center in BorderLayout

BorderLayout is often over simplistic when it comes to some UI styles, in these cases we need more elaborate layouts which we already have…​

What is the best way to write a GUI in Codename One : Use the designer or code the GUI?

One of the motivations we have to switch to the new GUI builder is the fact that it will remove the need to decide up-front whether you want to code the UI with the GUI builder or by hand. You could decide this dynamically on a specific Form.

Is Codenameone geofencing locations limited to 1?

It’s not, but it is sometimes hard to find out exactly how many locations were bounds and what are the platform limits in regards to location binding.

How to minimize gap between Tab icon and Tab text in Codename one?

There is a default padding within the FontImage class, the padding allows for a more whitespace which is often more visually pleasing. However, you can turn that off…​

Error during android build for native interface

Native interfaces are sometimes challenging especially if you just copy and paste code, this does need some native coding skills which is why we often recommend leaving the stubs and building the app. Then implementing the native code in the native IDE and copying the results back to Codename One.

CodenameOne APK is not zip aligned

Google broke Android builds again thru some changes to it’s build again, so we had to scramble to find the reason. One of the nice things about Codename One is that we have to do the scrambling after Google/Apple’s shenanigans for you…​

Specifying animations and Toolbar items in the resource editor

Toolbar didn’t exist during the days we developed the resource editor, we are bringing it more into the new GUI builder which will hopefully become our chief tool in the near future.

Why a String drawn on a Graphics object change its position depending on the used skin?

This is a bit of a challenging thread, drawString is core to the platform and it’s hard to figure out what is the reason for the inconsistency n this thread.

Avoid app from closing on app switching

Controlling lifecycle in mobile is problematic, a lot of the assumptions that are true for desktop just don’t carry over…​

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.