本文整理汇总了Java中android.webkit.WebView.loadUrl方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.loadUrl方法的具体用法?Java WebView.loadUrl怎么用?Java WebView.loadUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView
的用法示例。
在下文中一共展示了WebView.loadUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostExecute
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Boolean doit) {
if (!doit.booleanValue() || isCancelled()) {
if(DBG) Log.d(TAG, "WebViewDelayedInitTask canceled");
return;
}
if(DBG) Log.d(TAG, "starting creation of WebView in " + mParent);
Context c = mParent.getContext();
View content = LayoutInflater.from(c).inflate(R.layout.leanback_weblink_cardview_content, mParent, false);
mProgress = content.findViewById(R.id.progress);
mWebView = (WebView)content.findViewById(R.id.webview);
initWebView();
mParent.removeView(mPlaceholder);
mParent.addView(content);
// Load the url if it has been setup already
if (mUrl!=null) {
mWebView.loadUrl(mUrl);
}
mWebViewDelayedInitTask = null; // way to remember it is over
}
示例2: injectJsFile
import android.webkit.WebView; //导入方法依赖的package包/类
private void injectJsFile(WebView view) {
// String js = FileUtils.readFromFile("web/inject.js");
// Log.d(TAG, "injectJsFile: \n js = " + js);
view.loadUrl("javascript:" + "(function imgOnClick(){\n" +
" var imgs = document.getElementsByTagName(\"img\");\n" +
" for(var i = 0; i < imgs.length;i++){\n" +
" imgs[i].onclick = function(){\n" +
" jk.showBigImage(this.src);\n" +
" };\n" +
" }\n" +
"})()");
}
示例3: onPageFinished
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl("javascript:(function () {" +
" var objs = document.getElementsByTagName(\"img\");" +
" for (var i = 0; i < objs.length; i++) {" +
" objs[i].onclick = function () {" +
" window.imgClickListener.openImage(this.src);" +
" }" +
" }" +
"})()");
}
示例4: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new TwitterWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
mContent.addView(mWebView);
}
示例5: onCreateView
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Get the WebView element:
LayoutInflater lf = getActivity().getLayoutInflater();
rootView = lf.inflate(R.layout.fragment_about, container, false);
WebView webView = (WebView) rootView.findViewById(R.id.webView);
//Load the HTML file in the WebView:
webView.loadUrl("file:///android_asset/about.html");
return rootView;
}
示例6: shouldOverrideUrlLoading
import android.webkit.WebView; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (mCustomWebViewClient!=null){
boolean ret = mCustomWebViewClient.shouldOverrideUrlLoading(view,request);
if (ret){
return true;
}
}
view.loadUrl(request.getUrl().toString());
return true;
}
示例7: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webView = new WebView(this);
setContentView(webView);
webView.loadUrl("file:///android_asset/scheme.html");
}
示例8: b
import android.webkit.WebView; //导入方法依赖的package包/类
private void b(String str) {
WebView webView = (WebView) this.a.get();
if (webView != null) {
StringBuffer stringBuffer = new StringBuffer("javascript:");
stringBuffer.append("if(!!").append(this.e).append("){");
stringBuffer.append(this.e);
stringBuffer.append("(");
stringBuffer.append(str);
stringBuffer.append(")}");
String stringBuffer2 = stringBuffer.toString();
f.b(f.d, "-->callback, callback: " + stringBuffer2);
webView.loadUrl(stringBuffer2);
}
}
示例9: b
import android.webkit.WebView; //导入方法依赖的package包/类
private void b(String str) {
WebView webView = (WebView) this.a.get();
if (webView != null) {
StringBuffer stringBuffer = new StringBuffer("javascript:");
stringBuffer.append("if(!!").append(this.e).append("){");
stringBuffer.append(this.e);
stringBuffer.append(SocializeConstants.OP_OPEN_PAREN);
stringBuffer.append(str);
stringBuffer.append(")}");
String stringBuffer2 = stringBuffer.toString();
f.b(f.d, "-->callback, callback: " + stringBuffer2);
webView.loadUrl(stringBuffer2);
}
}
示例10: a
import android.webkit.WebView; //导入方法依赖的package包/类
public void a() {
WebView webView = (WebView) this.a.get();
if (webView != null) {
webView.loadUrl("javascript:window.JsBridge&&JsBridge.callback(" + this.b + "," +
"{'r':1,'result':'no such method'})");
}
}
示例11: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
Log.d(this.getClass().getSimpleName(), "onCreate: ");
webView = new WebView(WebViewActivity.this);
webView.getSettings().getJavaScriptEnabled();
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(OTHERS_GAMES_URL);
setContentView(webView);
}
示例12: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mWebView = new WebView(this);
mWebView.setScrollContainer(false);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
setContentView(mWebView, layoutParams);
Bundle args = getIntent().getExtras();
String url = args.getString(ARG_URL);
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
}
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl(url);
}
示例13: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
WebView webview = (WebView)findViewById(R.id.WebView);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("https://github.com/qoli/MiHomePlus/blob/master/README.md");
}
示例14: a
import android.webkit.WebView; //导入方法依赖的package包/类
public void a(String str) {
WebView webView = (WebView) this.a.get();
if (webView != null) {
webView.loadUrl("javascript:" + str);
}
}
示例15: updateNumsService
import android.webkit.WebView; //导入方法依赖的package包/类
public static void updateNumsService(WebView view) {
view.loadUrl("javascript:(function()%7Bfunction%20n_s()%7Bandroid.getNums(document.querySelector(%22%23notifications_jewel%20%3E%20a%20%3E%20div%20%3E%20span%5Bdata-sigil%3Dcount%5D%22).innerHTML%2Cdocument.querySelector(%22%23messages_jewel%20%3E%20a%20%3E%20div%20%3E%20span%5Bdata-sigil%3Dcount%5D%22).innerHTML%2Cdocument.querySelector(%22%23requests_jewel%20%3E%20a%20%3E%20div%20%3E%20span%5Bdata-sigil%3Dcount%5D%22).innerHTML)%2CsetTimeout(n_s%2C" + BADGE_UPDATE_INTERVAL + ")%7Dtry%7Bn_s()%7Dcatch(_)%7B%7D%7D)()");
}