Because the browser's processing is asynchronous. You could stick in a big wait (like you do earlier), and hope it's enough, or check-wait-loop - but a better way is to trigger whatever processing you want to happen on that value, from inside your Value(String) method.
Better and more relevant than Firebog here would be to set a breakpoint in your Value method. On Aug 4, 12:58 pm, Anamika <its.anubh...@gmail.com> wrote: > Pl. Hellllppppp, > Why below code is throwing nullPointer exception in last line > (when accessing javaInterface.mValue) > This line through NullPointer, so basically it is not being set. even > though the javascript is correct and has been verified using FireBug > that it returns expected string. > > ........................................................................... > ................................... > > ----- There are few lines above this code chunk but it is irrelevant > this problem > ----- > ------ > DemoJavaScriptInterface javaInterface = new > DemoJavaScriptInterface(); > storeView.addJavascriptInterface(javaInterface, "demo"); > //String jScript4 = ""; > solo.sleep(10000); > //storeView.loadUrl("javascript:var > mV=document.getElementById(\"color-link-box-top > \").getElementsByTagName(\"p\")[0].innerHTML;alert(mV);"); > > solo.sleep(2000); > > storeView.loadUrl("javascript:window.demo.Value(document.getElementById(\"c > olor- > link-box-top\").getElementsByTagName(\"p\")[0].innerHTML)"); > > System.out.println(javaInterface.mValue); //This line > through NullPointer, so basically it is not being set. > //Assert.assert() > > } > > final class DemoJavaScriptInterface > { > > String mValue; > public void Value(String myVal) > { > mValue = myVal; > } > DemoJavaScriptInterface() { > } > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en