[英]Get JavaScript value to android using WebView
I'm developing an application using a WebView. 我正在使用WebView开发应用程序。 The site uses a PHP username session variable, so I'd like to get that into my app and write it in my menu.
该站点使用一个PHP用户名会话变量,因此我想将其输入我的应用程序并将其写入菜单。
The problem is that I can't get the value from the JavaScript function: 问题是我无法从JavaScript函数获取值:
var utente=<?php echo json_encode($_SESSION['username']); ?>;
function setID() {
window.app.returnValue(utente);
}
I don't understand how to code the java for the app in android studio. 我不明白如何在android studio中为应用程序编写Java代码。
Try this: 尝试这个:
var utente= "<?php Print json_encode($_SESSION['username']) ?>" ;
function setID() { window.app.returnValue(utente); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.