generating function arguments in java
Posted
by aloishis89
on Stack Overflow
See other posts from Stack Overflow
or by aloishis89
Published on 2010-06-12T02:13:26Z
Indexed on
2010/06/12
2:22 UTC
Read the original article
Hit count: 204
I'm very new to java and am working on my first Android app. I am using the webview demo as a template. I am trying to generate a random integer between 1 and 12 and then call a certain javascript function based on the result. Here's what I have:
int number = 1 + (int)(Math.random() * ((12 - 1) + 1));
number = (int) Math.floor(number);
String nextQuote = "javascript:wave" + number + "()";
mWebView.loadUrl(nextQuote);
So mWebView.loadUrl(nextQuote)
will be the same as something like mWebView.loadUrl("javascript:wave1()")
I just want to know if what I have here is correct and will work the way I think it will. The application isn't responding as expected and I suspect this bit of code is the culprit.
© Stack Overflow or respective owner