网页标题整改
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
public class JavascriptInterface {
|
||||
private Activity context;
|
||||
|
||||
public JavascriptInterface(Activity context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.util.AttributeSet;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* pdlive对H5页面开放的web控件
|
||||
*/
|
||||
public class PDLiveWebView extends WebView {
|
||||
|
||||
public PDLiveWebView(@NonNull Activity context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public PDLiveWebView(@NonNull Activity context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public PDLiveWebView(@NonNull Activity context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
@SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
|
||||
private void init(Activity context) {
|
||||
getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
getSettings().setDomStorageEnabled(true);
|
||||
this.addJavascriptInterface(new JavascriptInterface(context), "androidObject");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user