[英]WebView - JavascriptInterface
i'm using component navigation.我正在使用组件导航。 In the application, I have WebView which, if a successful transaction, returns success in javascript, and if unsuccessful it returns unsuccess.
在应用程序中,我有 WebView,如果交易成功,则在 javascript 中返回成功,如果不成功则返回不成功。 Now I use @JavacscriptInterface here.
现在我在这里使用@JavacscriptInterface。 My question is whether and how I can use Navigation.findNavController, for example if it is a success to open a fragment, if it is unsuccessful to open another fragment.
我的问题是我是否以及如何使用 Navigation.findNavController,例如,如果打开一个片段成功,如果打开另一个片段不成功。 I have a problem with how to get View In class where is @JavascriptInterface
我有一个问题,如何在课堂上查看 @JavascriptInterface 在哪里
You Need to create @JavascriptInterface method and for success and unsuccess.您需要创建 @JavascriptInterface 方法以及成功和失败。 also you need to add this interface in webview :
您还需要在 webview 中添加此接口:
Add interface:添加接口:
mWebView.addJavascriptInterface(new YourInterfaceClass(), "webinterface");
public class YourInterfaceClass{
public YourInterfaceClass() {
}
@JavascriptInterface
public void success () {
//do here
}
@JavascriptInterface
public void unsuccess() {
//do here
}
}
and call in your webpage like this : webinterface.success() or webinterface.unsuccess()并像这样调用您的网页: webinterface.success() 或 webinterface.unsuccess()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.