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

Web and WebWorks Development

Reply
Highlighted
New Developer
Posts: 31
Registered: ‎04-21-2011
My Device: Playbook
My Carrier: N/A

Accessing blackberry.* javascript APIs from GWT

I'm wondering if anyone has successfully managed to call back into the Playbook blackberry.* APIs from a GWT application?

 

I have included a snippet below that shows my problem. I'm not surprised that the blackberry API can't be found in GWT development mode, but when I deploy it to the Playbook in the simulator I still get the error:

 

"error registering handlers: com.google.gwt.core.client.JavaScriptException: (ReferenceError): Can't find variable: blackberry"

 

Does anyone know how to correctly refer to the blackberry variable from within GWT so we can access platform-specific APIs?

 

 

private void registerHandlers() {
 	try {
 		regOnBackground();
 	} catch (Exception e) {
 		Window.alert("error registering handlers: " + e);
 	}
}

private native void regOnBackground() /*-{

 	  blackberry.app.event.onBackground(this.@org.app.Main::onBackground());

}-*/;


public void onBackground() {
 	System.out.println("onBackground");
 	Window.alert("onBackground");
}