We use a countdown latch instead:

String returnValue;
private CountDownLatch latch = null;

public String run(String javaScript, int waitInMilliSecs) {
latch = new CountDownLatch(1);
runJS(javaScript); // this method just runs the given javascript in the 
WebView.
try {
latch.await(waitInMilliSecs, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } return returnValue;
}

 ...
 ...

 // method being called by the javascript in WebView
public void setValue(String value) {
try {
// do your stuff here with 'value':
returnValue = value;
}
finally {
try { latch.countDown(); } catch (Exception e) {}
}
}

-- 
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

Reply via email to