Issue
I'm sending a class to my site using android web view just like this:
webView.addJavascriptInterface(data, "info")
I wanted to know is there any way that I find out what functions and what variables are there in info class on the web side?
for example, if my data class be like this:
class Data(){
val name = ""
val family = ""
fun getName():String = name
fun getFamily():String = family
}
what javascript code I should use to understand the info class has two variables name and family? currently, my web side is just like this:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
document.write(info.getName());
</script>
</body>
</html>
and using that I can access to name variable which is passed by android side, how can I understand also there is a getFamily function too?
Solution
you can use a built-in method of javascript you can get the whole method of an object object.keys(name_of_object)
.
for example, in your case, it would be like this
document.write(object.keys(info));
and It will print
getName()
and getFamily()
Answered By - Mohammad Derakhshan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.