maik
maik

Reputation: 3

codenameone setURL with HTML file doesn't work on device

i'm re writing an app with codename one for other devices other android. On the simulator everything is working fine, iv'e got some buttons that, when pressed, give access to an HTML page, the actual code for this is:

 wifi.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ev){
            Form form = new Form("WiFi");
            Container container = new Container();

            WebBrowser wb = new WebBrowser();
            container.addComponent(wb);
            wb.setURL("jar:///assets/html/wifi.html");

            System.out.println("url:"+wb.getURL());

            Command backCommand = new Command("Back") {
            public void actionPerformed(ActionEvent ev) {
                wifi.getComponentForm().showBack();
            }};

            form.addCommand(backCommand);
            form.setBackCommand(backCommand);
            form.addComponent(container);
            form.show();
        }
    });

When i first want to getURL() back, the string is empty; then when i want to build for an android device (Galaxy Nexus with Android 4.3) when i tap on the button it returns me nothing but a blank page. I also tried with an http link like https://www.google.com, on simulator no problem, on device the usual blank page. Then i tried modifying the position of the html file, putting it in src like for the image file (that works on device), but still nothing. I've checked the developer guide and every example i could find, and everyone got no problem with this (and on the simulator me neither). Could anyone solve this? Thank you :)

Upvotes: 0

Views: 617

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

Place the file in the root of the src directory and point directly at it without the assets hierarchy for it to work properly across platforms.

Upvotes: 0

Related Questions