0

I want to pass the value of a LocalURL to another Screen. I have tried this but all I get is blank Screen: BlackBerry - how to pass data like Intent.putExtra() in Android

Like in android:

(In Screen1)

        WebView webView;
        webView = (WebView) findViewById(R.id.webView);
        Bundle extras = getIntent().getExtras();
        String value = "file:///android_asset/errorpage.html";
        if (extras != null) {
            value = extras.getString("keyHTML");
        }

and (in Screen2)

        Intent i = new Intent(this, Screen1.class);
        i.putExtra("keyHTML", "file:///android_asset/page2.html");
        startActivity(i);

How do I implement something like this in Blackberry, I currently use:

BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
            myBrowserFieldConfig.setProperty(
                    BrowserFieldConfig.NAVIGATION_MODE,
                    BrowserFieldConfig.NAVIGATION_MODE_POINTER);
            BrowserField browserField = new BrowserField(
                    myBrowserFieldConfig);
            sscreen = new MainScreen();
            sscreen.add(browserField);
            if (name.equals("Santa Claus")) {
                Ui.getUiEngine().pushScreen(sscreen);

                browserField.requestContent("local:///santa.html");

            } else if (name.equals("Christmas")) {
                Ui.getUiEngine().pushScreen(sscreen);

                browserField.requestContent("local:///christmas.html");

But I see it takes a while before it displays the HTML, I thought if I could pass data as it is in android, then it would open faster.

EDIT

in NewScreen

public NewScreen(String url) {
    BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
    myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
            BrowserFieldConfig.NAVIGATION_MODE_POINTER);
    BrowserField browserField = new BrowserField(myBrowserFieldConfig);
    add(browserField);
    url = "local:///errorpage.html";
    browserField.requestContent(url);
}

in OldScreen

if (check.equals("1") || check.equals("001")) {
                    NewScreen newscreen = new NewScreen("local:///page1.html");
                    UiApplication.getUiApplication().pushScreen(newscreen);

The NewScreen is pushed but still shows the default value "url = "local:///errorpage.html";" I thought it ought to change to the new value set in OldScreen "local:///page1.html" when run. Please explain.

Community
  • 1
  • 1
  • your if loop is working ?. I think , its not going to the if condition. – Rince Thomas Mar 24 '14 at 02:55
  • I removed the "url = "local:///errorpage.html";" from Newscreen, and it loads the url in the OldScreen. However, it takes the same time as in sscreen = new MainScreen(); sscreen.add(browserField); if (name.equals("Santa Claus")) { Ui.getUiEngine().pushScreen(sscreen); browserField.requestContent("local:///santa.html"); – Oluleye IResþekt Idowu Mar 24 '14 at 10:56
  • Just to clarify - your issue here is that if, in NewScreen, you use the same URL in a new BrowserField, it takes the same amount of time to display as it took to display in OldScreen? Correct? This is to be expected. If you want to speed this up, and you know the same URL is going to be used, then you can just pass the BrowserField and add it (removing it from the previous screen first). Otherwise it will take the same amount of time (less a little bit because of the possible time saving because of data in network caches). – Peter Strange Mar 25 '14 at 09:08
  • @PeterStrange Could you please write a code in this manner... What I am saying is that in the sscreen instance above, a screen is pushed and the URL I input is shown, it just takes time.(This is from one JAVA class) So I thought if I created a new class that contains all the parameters of BrowserField, so all I needed to supply the Newscreen was just the URL then it should load faster. But it still takes the same time. – Oluleye IResþekt Idowu Mar 25 '14 at 11:40
  • You already have code that passes in the URL to the new Screen - you just need to do the same for the BrowserField. Is this causing you a problem? Be aware that when you delete the Field from the current screen, it will re-display without the BrowserField, which might look a bit weird. – Peter Strange Mar 25 '14 at 11:56
  • What do you mean by "I just need to do the same for the BrowserField" I am not having a problem, in the simulator, it appears to take say 5seconds before the html is shown.. I am looking to make it faster hence responsive. If you know how I can achieve this, will appreciate. – Oluleye IResþekt Idowu Mar 25 '14 at 14:39

1 Answers1

1

try this -

new_screen = new new_screen(your_url);
UiApplication.getUiApplication().pushScreen(new_screen);

In your new_screen class -

public class new_screen extends MainScreen{
public new_screen(String url){
//here you will get the value of url  from the variable url.

  }
    }
Rince Thomas
  • 4,158
  • 5
  • 25
  • 44