BlackBerry Browserfield Field page Call back Java code

Source: Internet
Author: User
Tags call back

Demand:

Going to use HTML to develop the BlackBerry BB 7 app for navigation, data display,

Use Java to develop part of the page navigation, menu, background program

But don't webworks.


This requires invoking the business logic of Javascript,javascript invoke the BlackBerry Java application from the HTML page.


The example code is as follows:

Package mypackage;
Import net.rim.device.api.browser.field2.*;
Import net.rim.device.api.script.ScriptableFunction;
Import net.rim.device.api.ui.*;
Import Net.rim.device.api.ui.component.Dialog;

Import net.rim.device.api.ui.container.*; public class Browserfielddemo extends UIApplication {public static void main (string[] args) {Browserfiel
        Ddemo app = new Browserfielddemo ();
    App.entereventdispatcher ();
    Public Browserfielddemo () {Pushscreen (New Browserfielddemoscreen ()); } class Browserfielddemoscreen extends Mainscreen {public browserfielddemoscreen () {BROWSERFIELDCONFI
        G Mybrowserfieldconfig = new Browserfieldconfig (); Mybrowserfieldconfig.setproperty (Browserfieldconfig.navigation_mode,browserfieldconfig.navigation_mode_pointer
        );
        
        Browserfield Browserfield = new Browserfield (mybrowserfieldconfig);
        Add (Browserfield);
        String url = "Http://www.blackberry.com"; URL ="Local:///index.html"; try {browserfield.extendscriptengine ("Myblackberry.hello", new Scriptablefunction () {public Object Invoke (Object thiz,final object[] args) {//here Args'll give to params passed by JAVASCRI
			                  PT//function//args[0] = Hello and args[1] = World
			    	TODO do your tasks here ... 
			                Uiapplication.getuiapplication (). Invokelater (New Runnable () {public void run () {
			                Dialog.alert ((String) args[0]);
			            Dialog.alert ((String) args[1]);
			    	
			        }
			        });
			    return thiz;
		}
			});
		catch (Exception e) {//TODO auto-generated catch block E.printstacktrace ();
    } browserfield.requestcontent (URL); }
}


 




Reference:

Passing values from a Web page to your App-android/blackberry

Http://stackoverflow.com/questions/10073810/passing-values-from-a-web-page-to-your-app-android-blackberry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.