Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 11
Registered: ‎10-02-2010
My Device: Curve 8900
My Carrier: Rogers

BrowserField problem with OS6

Hello,

 

first, let me thank you all for the help you're giving on this forum, it certainly helped me a lot the past couple of days. I'm now wondering if an issue I'm currently getting is a bug in the new OS6 or if it's just me who's doing something incorrect.

 

Here's the deal: I have a BrowserField that's displaying html data in my application using 

displayContent(string,string). I configured my object using BrowserFieldConfig and set a new BrowserFieldController to handle url requests. Because the html data comes from memory, I want references to things like the css file to be redirected to memory data as well (the original html data references an external css file, I prefer not to modify it). In the handleResourceRequest() method, I check if the request is for the css file and if so, I create an InputConnection object to feed the BrowserField with the css data. This way, instead of trying to access http://website.com/file.css, the browser gets a stream with the content of the file, taken from the application's resources.

 

All of that works very well in OS5, on several devices such as the 8900 and the 9550. Unfortunately, when I tried on OS6 with the 9800 simulator (I don't have the real device), it failed. All the calls are processed the same way, handleResourceRequest() is called and returns valid css data, but the browser doesn't use the result. Debugging didn't show anything differrent from the OS5 scenario, it's like the browser was silently refusing the stream that's sent back. Could someone help me with this issue?

 

Stripped code:

main()
{
  String sHtml = "<html><body>...";

  BrowserFieldConfig browserConfig = new BrowserFieldConfig();
  browserConfig.setProperty(BrowserFieldConfig.CONTROLLER, this);
		
  BrowserField fldBrowser = new BrowserField(browserConfig);
  fldBrowser.displayContent(sHtml, "local://"); //Dummy prefix
}

InputConnection handleResourceRequest(BrowserFieldRequest request)
{
  if(request.getURL().startsWith("local://"))
  {
    String sFileName = request.getURL().substring(8);
    InputStream stream = getClass().getResourceAsStream("/"+sFileName);
    return new InputStreamToConnection(stream);
  }
  return null; //The real code has extra processing here
}


//Helper class used by the browser field to access internal resources
class InputStreamToConnection implements InputConnection
{
  InputStream m_dataStream;
  public InputStreamToConnection(InputStream stream) {
    m_dataStream = stream;
  }
  public DataInputStream openDataInputStream() throws IOException {
    return new DataInputStream(m_dataStream);
  }
  public InputStream openInputStream() throws IOException {
    return m_dataStream;
  }
  public void close() throws IOException {
    m_dataStream.close();
  }
}

 

Thank you,

Cyril

 

New Contributor
Posts: 6
Registered: ‎10-03-2010
My Device: Not Specified

Re: BrowserField problem with OS6

Hi,

 

Any progress on this issue? It's a big blocker for me - I want to display video in a BrowserField, and this is a major hurdle  Smiley Sad

 

Thanks,

 

Nick

BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField problem with OS6

Have you tried loading the same page/css/etc in the BlackBerry Browser?  Does it display correctly there?  This will help rule out a page/browser issue versus and issue with the BrowserField itself.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Contributor
Posts: 6
Registered: ‎10-03-2010
My Device: Not Specified

Re: BrowserField problem with OS6

Yes, it displays fine in the BB browser. My code also works in the simulator. It's only when I put my fully signed code onto the device (BB Curve 5820) that I get a problem.

 

I'd like to avoid workarounds... because I'm displaying everything from file:///SDCard it seems to work brilliantly in the browser, but BrowserField is not the same beast on the device  Smiley Sad

 

Thanks for the quick reply  Smiley Happy

BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField problem with OS6

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

Currently, 6.0 is only available for the BlackBerry Torch and note the following:

 

Appropriate version of the BlackBerry JDE and BlackBerry Java SDK

http://supportforums.blackberry.com/t5/Java-Development/Appropriate-version-of-the-BlackBerry-JDE-an...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Contributor
Posts: 11
Registered: ‎10-02-2010
My Device: Curve 8900
My Carrier: Rogers

Re: BrowserField problem with OS6

[ Edited ]

Thanks for answering that post. I can confirm that linking to the same css file directly in the page works perfectly fine. Actually, that's the current workaround I'm using for OS6, I'm extracting the CSS from the resources of the app and I send "file//store/.../file.css" to the browser. I would rather have it work like it does in OS5 though.

 

I'm testing the app on the Torch simulator, latest version I could download last week. I'm building the app with version 6 of the JDE to make sure this is not what's causing the issue. Btw, I also notieced several problems with the layout of the page in OS6, it seems that it does not like many CSS attributes, including basic ones such as "background-attachment:fixed" which does nothing in the new browser.

Developer
Posts: 133
Registered: ‎07-20-2009
My Device: Not Specified

Re: BrowserField problem with OS6

I got the same problem, Did you solve the problem yet? If you do can you give me some hints?

Super Contributor
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above
My Carrier: none

Browsersession without menu item

hi,

 am new to this blackberry...   so i wanna clarify some doubts.

     i want to create a help screen for our application same as provided by blackberry.

i can create that using browser session because am using blackberry4.5 but the menu items have to be changed.

it should have link to my html files.

 

how can i change the default menu item from the BrowserSession and add my own.

Developer
Posts: 90
Registered: ‎06-03-2009
My Device: Dev Alpha B
My Carrier: None atm.

Re: BrowserField problem with OS6

Regarding simulator. Yesterday I downloaded 6.0.0.246 which works a lot better for my app than the 6.0.0.141, I don't know if it would change anything for you, but make sure you get the 6.0.0.246 if you are not already using it.

Br
J. C. Nielsen

Attended DEVCON 2010

Free Tibet
Contributor
Posts: 14
Registered: ‎09-27-2010
My Device: Not Specified

Re: BrowserField problem with OS6

Hey, I am experiencing a similar problem. It seems the simulator will not render the css if it is returned in a ByteArrayInputConnection. This works fine on 5.0.0. I have also tried downloading the most recent simulator like the previous post suggested but haven't had success. I have yet to test on a real device so I'm not sure if this is a simulator bug or something else?

 

The code below is contrived, but hopefully points out the issue I'm having. Any ideas for workarounds?

 

Thanks

 

 

 

public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception
{
  if ( resourceName.endsWith(".css") ) {
    return new ByteArrayInputConnection( IOUtilities.streamToBytes( super.handleResourceRequest(request).openInputStream() ) );
  }

  return super.handleResourceRequest(request);
}