Building a Web Browser App for Blackberry Playbook Simulator

November 17, 2010

The blackberry playbook simulator doesn't yet include the web browser application, but I found it pretty easy to write my own using the class and calling the loadUrl method. This class also has a loadString(code, mimeType) and executeJavaScript method that looks interesting.

Here's the code for a simple browser:

	import flash.display.Sprite;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.text.TextInput;
	// The following metadata specifies the size and properties of the canvas that
	// this application should occupy on the BlackBerry PlayBook screen.
	[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
	public class PlaybookTest extends Sprite
		private var addressInput:TextInput = null;
		private var webView:QNXStageWebView = null;
		public function PlaybookTest()
			addressInput = new TextInput();
			addressInput.x = 10;
			addressInput.y = 10;
			addressInput.text = "";
			var goButton:LabelButton = new LabelButton();
			goButton.label = "Go";
			goButton.x = addressInput.width + 10;
			goButton.y = addressInput.y;
			goButton.addEventListener(MouseEvent.CLICK, go);
			var closeButton:LabelButton = new LabelButton();
			closeButton.label = "Close";		
			closeButton.addEventListener(MouseEvent.CLICK, closeWindow);
			closeButton.x = (stage.stageWidth - closeButton.width) - 10;
			closeButton.y = 10;
			webView = new QNXStageWebView(); 
			webView.stage= stage;
			webView.viewPort = new Rectangle(10,100,stage.stageWidth,stage.stageHeight-100);
			webView.enableCookies = true; 
			webView.enableJavascript = true; 
			webView.enableScrolling = true; 
			stage.nativeWindow.visible = true;
		private function closeWindow(event:MouseEvent):void{
		private function go(event:MouseEvent):void {

Here's a screenshot of the app:

Blackberry Playbook Simple Browser App

Like this? Follow me ↯

You might also like:

1 person found this page useful, what do you think?


I noticed that QNXStageWebView was not in the API docs (from what I can see). How did you find out the methods for it?
Hi Ray, I found it by browsing through the "BlackBerry Tablet OS SDK 0.9.0 for Adobe AIR" library in the Package Explorer in Flash Buider.

I didn't realize it was undocumented :)
Nice - I keep forgetting we can do that. ;)
You should be able to make a local URL request to


where app:// represents the application install directory and "foo" is some file underneath it.
Try app:/ notice it has ONE slash.
Actually I may be wrong on that.

So - yesterday I was speaking with Brian Rinaldi. And he mentioned that he saw oddness using app:// syntax under Android. THat may be at play here.

Instead of using app://, you could use FIle.applicationDirectory.nativePath. That should give you a pointer to the directory - and then you just append the file name.

That's not _exactly_ the syntax, but you get the idea I hope.
Thanks for the useful discussion and comments Louis and Ray. I was interested in doing the same thing (to see if I could port a jQuery Mobile app), which is why I tried to figure out how to embed the browser in the first place. I also tried the app:// url without luck. I'll give the File.applicationDirectory.nativePath option a try when I get a chance.
Hi Pete. I run into the same white page that Basti does. Did something change in the SDK that broke the Browser App code?
Hi Guys, yes this was with the first beta, so things must have changed since then. I'm not sure when I'll get a chance to try this again, but if anyone can find a workaround feel free to post it here.

Foundeo Inc.