I am trying to fill a TextView
located inside WebView
(in Android) with random email generated by Kotlin
function
using JavaScript but not found any solution.
My Kotlin
function
for generating random email address
fun getSaltString(): String? {
val SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
val salt = StringBuilder()
val rnd = Random()
while (salt.length < 7) { // length of the random string.
val index = (rnd.nextFloat() * SALTCHARS.length) as Int
salt.append(SALTCHARS[index])
}
return salt.toString()
}
And here is the call to the above function using Kotlin getSaltString()+"@gmail.com"
but what I don't know how to call it from JavaScript
?
My JavaScript
call so far
myWebView.loadUrl("javascript:(function(){document.getElementById(\"user_email_login\").value = \"I don't know how to call @gmail.com\";\n})()");
Any help would be highly appreciated. Thanks in advance:)