Codename One – Color of a pressed button on iOS

I have the following very simple code:

    Form hi = new Form("Hi World", BoxLayout.y());
    Button button = new Button("Click me", "MyButtonUIID");

The following code is my theme.xml:

<resource majorVersion="1" minorVersion="9" useXmlUI="false">
    <theme name="Theme">
        <val key="@includeNativeBool" value="true" />
        <val key="MyButtonUIID.bgColor" value="ff3300" />
        <val key="" value="ff66" />
        <val key="" value="255" />
        <val key="MyButtonUIID.sel#bgColor" value="ff66" />
        <val key="MyButtonUIID.sel#transparency" value="255" />
        <val key="MyButtonUIID.transparency" value="255" />

On every Android version from 4.4 to 8 (and in the Simulator with Android and iPhone skins) I get a red button that becomes green while it’s pressed (during all the time that it’s pressed).
On every iOS version from 8 to 11 I get a button that is always red (or sometimes it becomes green for a very very short moment).

So… how can I get in iOS the same behavior of Android and of the Simulator? Am I missing something or is it a bug?

Styling the textComponent

How to keep the textComponent both float label and hint at the center of the screen horizontally. I’ve tried the alignment of the uiid like floatingHint, TextComponent, TextField etc to center in theme but nothing works.

TextModeLayout tl = new TextModeLayout(3, 1);

TextComponent fname = new TextComponent().labelAndHint("Fname");

add(tl.createConstraint().widthPercentage(100).horizontalAlign(Label.CENTER), fname);

Codename One – Flags for all countries

I have a code very similar to the Uber clone app to show a country picker form. I understand that the flags are taken from flagResource ="/flags.res");, from the Codename One SMS Library

The problem is that a lot of flags are missing. A user may be sorry if the flag of his/her country is not there.

How can I insert all the flags? has text relocations error in cn1

I’ve used zbarscanner lib in cn1 and it worked fine. I have recently updated the app and has the following bug that cause app crash. The error occured in nougat nokia 5 device. I checked the previous version of the app which works fine.

02-08 16:24:58.792 592-592/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.capitaleyenepal.lenovo, PID: 592
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.capitaleyenepal.lenovo-2/lib/arm/ has text relocations
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(
at java.lang.Class.newInstance(Native Method)
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)

Unzipping .zip folder with Zipme Library in Codename One

This is as a followup to the question that I asked here:
What is the correct way to display a HTML file downloaded and saved in the file system using codename one?

I am successful to display a html file from a folder using webview. The trick is to add the “file://” when setting the url as shown below:


If this is not by your design then I can file an RFE. Nonetheless, next I hit an Unzipping challenge which I think might be related to the “file://” issue above.

When unzipping a .zip file using the Zipme cn1lib, everything extracts OK on simulator but fails on device. I had to root a phone in order to see what exactly is going on. I found that some files are not extracted.

Checking on the DDMS confirmed my findings. Every so often I see this error: W/System.err: (No such file or directory)

Then, when I try to display the index file (which should fail because of the above missing files), I get this error:
I/System.out: showKeyboard false
I/System.out: showKeyboard false
D/WebView: loadUrl=file:///data/user/0/
W/cr_media: Requires BLUETOOTH permission
E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)

Below is the code I am using to unzip:

    System.out.println("Finding FILE TO UNZIP: ");
    InputStream zipFile = Storage.getInstance().createInputStream("folderName"+".zip");
    //InputStream zipFile = FileSystemStorage.getInstance().openInputStream(fs.getAppHomePath()+"folderName"+".zip");
    System.out.println("ZIPPED FILE FOUND: ");
    Unzip(zipFile, "/"+ "folderName");
    System.out.println("UNZIPPED SUCCESFULLY");
catch (IOException ex)
    Log.p(ex.getMessage(), 0);
catch (Exception ex)

The above codes calls the following method as copied from the link below, with some edits that I hoped would allow extracting to a folder by checking whether the next entry during the unzipping process is a directory or not.

public void Unzip(InputStream is_zipFile, String str_dirDest) 
    InputStream is;
        is = is_zipFile;
        ZipInputStream zipStream = new ZipInputStream(is);
        ZipEntry entry;

        // create a buffer to improve copy performance later.
        byte[] buffer = new byte[2048];
        System.out.println("TRYING TO UZIP: ");

        while ((entry = zipStream.getNextEntry()) != null) 
            FileSystemStorage fs = FileSystemStorage.getInstance();
            String str_name = entry.getName();
            String dir;
            String str_outdir = FileSystemStorage.getInstance().getAppHomePath();
            //FileOutputStream fileoutputstream;
            File newFile = new File(str_outdir, str_name);
            boolean overwrite = false;
            if (str_outdir.length() > 0) 
                str_outdir = str_outdir + "/" + str_dirDest;

            //extractFile(zin, outdir, name);
            String outpath = str_outdir + "/" + entry.getName();
            OutputStream output = null;

                if (entry.isDirectory()) 

                    fs.mkdir(str_outdir + "/" + str_name);
                    entry = zipStream.getNextEntry();
                    File file = new File(str_outdir + File.separator + str_name);
                    File parent = file.getParentFile();
                    if (!parent.exists()) 


                System.out.println("UNZIPPING:- " + str_name);
                output = FileSystemStorage.getInstance().openOutputStream(outpath);
                int len = 0;
                while ((len = > 0) 
                    output.write(buffer, 0, len);
            catch (Exception e) 
                //"Unzipping Error!", ""+e, "Ok", null);

                if (output != null) 
    } catch (IOException ex) {
        Log.p(ex.getMessage(), 0);


Codename One – Recognize the same user with GoogleConnect

My question is about GoogleConnect (with Codename One), but maybe it can be valid also for FacebookConnect.

The problem is that the following code gives me a token that changes every time: using the same username and password of Gmail, I get a different token after every login. So… how can I recognize the same user?

String token = GoogleConnect.getInstance().getAccessToken().getToken(); value differs between iphone and CN1 simulator using SimpleDateFormat

Actual IPhone and Iphone CN1 Simulator values vary for my Date object, which causes me downstream errors when trying to do other formatting to them (and expecting them in a specific format).
I am using Codenameone SimpleDateFormat class to convert a string (but in an Object) of value ‘20180201 23:59:00’ into a java.util.Date object.
My code is below:

    public static java.util.Date ObjectToDate(Object datestr) {
    if (datestr == null) {
        return null;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
    try {
        return simpleDateFormat.parse(String.valueOf(datestr));
    } catch (ParseException e) {
        // TODO Auto-generated catch block
    return null;

I place the value of my conversion into a screen field so i can verify it, using:
(have replaced the object itself with the date string that doing object.toString() returns)
DateFormatting.ObjectToDate(“20180201 23:59:00”).toString()
and i get back

In Simulator:
Thu Feb 01 23:59:00 GMT 2018

And on Actual iphone i get:
1 February 2018

Why? I would have thought it would be the same format as i used the com.codename1.l10n.SimpleDateFormat class to format it.
Many thanks

codenameone video in landscape is not filling screen

I’m working on a CodeName One app which includes a video player.
I’ve setup my form layout using the new gui builder and a Constraint layout.
in which I have a borderlayout container which should fill the entire with of the display.
In my code I’m creating a MediaPlayer and adding it to the center of the container (I have also tried North).
The issue is when the app is in landscape the video is not filling the width of the screen. In Portrait it is working as expected.
Any suggestions on how to achieve this?

Here’s a screenshot from the simulator showing the issue;
enter image description here