如何在 SL4A 上从 python 调用 javascript 方法?
我正在使用 Python 和 SL4A 编写 Android 应用程序。该应用程序使用我希望刷新的网络视图。我计划通过在包装 doRefresh() javascript 函数中利用 javascript location.replace() 来实现此目的。我遇到的问题是我不知道如何从 Python 代码的主事件循环中调用 javascript 函数。
有没有办法直接调用方法呢?
或者
有没有办法通过按钮的 onClick 和模拟屏幕点击来间接调用该方法?
谢谢。
I am writing an Android app using Python and SL4A. The app uses a webview that I wish to refresh. I plan on doing this by utilising javascript location.replace() within a wrapping doRefresh() javascript function. The problem I have is that I do not know how to call the javascript function from within my main event loop within the Python code.
Is there a way to directly call the method?
or
Is there a way to indirectly call the method say via a button's onClick and a mimic screen tap?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 JavaScript 中等待刷新事件(这将是自定义事件),该 JavaScript 正在等待从 Python 脚本发布的事件。 JavaScript 和 Python 之间的唯一通信层是通过事件。
You'll need to wait for a refresh event (this would be a custom event) in your JavaScript that is waiting for an event posted from your Python script. The only communication layer between JavaScript and Python is via events.