java - Using Browserfield.displayContent with <frame> that has an external url -


i trying create screen blackberry 5.0+ app has banner @ top , browserfield underneath views external site. banner hosted on 1 site , content browserfield hosted on another.

originally tried using 2 browserfields had issues when several devices did not display banner , showed content underneath. furthermore when screen same setup displayed app crash illegalstateexception. did bit of research , seems browserfield seems have trouble when several instances of exist @ once.

so in order around issue have combined both browserfields one, using frame tag in html, hopes of displaying banner ad in first frame , content underneath in second frame.

the html made works in normal browser:

<!doctype html> <html>       <frameset rows="10%,90%">              <frame scrolling="no" src="http://4.bp.blogspot.com/_cz1hhhanngc/ti0xscvlw8i/aaaaaaaabps/sfeo4e3234k/s1600/head-mp-700x88.jpg" noresize="noresize" frameborder="0">               <frame src="http://www.penny-arcade.com"  frameborder="0">       </frameset> </html> 

what doing reading html in text, removing \n , \rs , putting in following method: browserfield.displaycontent(html,"http://localhost");

this method supposed display html in browser, instead on simulator this:

enter image description here

on device blank screen. don't know whats going on displaycontent() method, assume doesn't allow external sites? don't know options point on. there kind of fix this, library can use or other way implement this?


edit:

so @nate suggested change doctype tag, , posted screenshot of html working. did , still same results, going post code i'm using make screen. here is:

public final class myscreen extends mainscreen {    /**     * creates new myscreen object     */    private browserfield browserfield;    public myscreen()    {                 // set displayed title of screen                settitle("mytitle");         browserfieldconfig config = new browserfieldconfig();     config.setproperty(browserfieldconfig.viewport_width, new   integer(display.getwidth()));         config.setproperty(browserfieldconfig.navigation_mode,     browserfieldconfig.navigation_mode_pointer);      config.setproperty(browserfieldconfig.initial_scale, new float(1.0));      config.setproperty(browserfieldconfig.user_scalable, boolean.false);      //supposed prevent invalidstateexception refreshing     protocolcontroller eventsprotocolcontroller = new protocolcontroller(browserfield)     {       public void handlenavigationrequest(browserfieldrequest request) throws exception       {         browserfield.setfocus();         super.handlenavigationrequest(request);       }    };     config.setproperty(browserfieldconfig.controller, eventsprotocolcontroller);    browserfield = new browserfield(config);      try    {       string embeddedlinkframe = readtextfile("frame.html");       browserfield.displaycontent(embeddedlinkframe, "http://localhost");    }    catch (exception e)    {       system.out.println(e.getmessage());    }    add(browserfield);    }     public string readtextfile(string fname)     {      string result = null;       datainputstream = null;      try            {       = new datainputstream(getclass().getresourceasstream("/" + fname));                byte[] data = ioutilities.streamtobytes(is);        result = new string(data);      }       catch (ioexception e)       {            system.out.println(e.getmessage());      }                 {       try                {           if (null != is)                       is.close();         }                 catch (ioexception e)                 {             system.out.println(e.getmessage());        }      }       return result;  }  } 

ok, apologies first answer. think doctype red herring (but didn't have java code @ time).

i see few potential problems:

network connectivity

first, case, make sure have network connectivity device, or simulator. may include mds simulator running. can test connectivity normal browser app, checking website know running. believe if have total lack of connectivity (i.e. network disabled), frames showing text / urls. however, believe have this:

could not select proper transport descriptor for: http://www.penny-arcade.com

instead of showing null, show.

adding browserfield

next, think there problem asking browser field display content before you've added field. switch order of 2 lines of code this:

   add(browserfield);     try    {       string embeddedlinkframe = readtextfile("frame.html");       browserfield.displaycontent(embeddedlinkframe, "http://localhost");    }    catch (exception e)    {       system.out.println(e.getmessage());    } 

i believe behaviour if have these lines out of order, however, blank browser field.

viewport properties

lastly, not recommend setting page properties programmatically, you've done. although not going keep page displaying, i'd recommend putting properties in html meta elements:

<head>     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">  </head> 

source: blackberry.com


update: protocol controller

unfortunately, simulator acting up, , declining support hot-swap right now. so, it's hard me run many times, , collect decisive results. but, looks me removing protocolcontroller object prevents problem happening me. (maybe can clarify why you're using protocol controller in situation?). if answer motivation, might @ poster's full comments it's usefulness.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -