本文整理汇总了Java中com.tencent.smtt.sdk.WebView类的典型用法代码示例。如果您正苦于以下问题:Java WebView类的具体用法?Java WebView怎么用?Java WebView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebView类属于com.tencent.smtt.sdk包,在下文中一共展示了WebView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldOverrideUrlLoading
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
String decode;
try {
decode = URLDecoder.decode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
// No handling
return false;
}
if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
callback(decode);
return true;
} else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
stateCheck(decode);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
开发者ID:androidDaniel,项目名称:riched_editor_x5,代码行数:20,代码来源:RichEditor.java
示例2: onProgressChanged
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public void onProgressChanged(WebView view, int newProgress)
{
super.onProgressChanged(view, newProgress);
if (newProgress == 100)
{
// 网页加载完成
mTopProgress.setVisibility(View.GONE);
}
else
{
// 加载中
hideProgressWithAnim();
mTopProgress.setNormalProgress(newProgress);
}
super.onProgressChanged(view, newProgress);
}
开发者ID:stytooldex,项目名称:stynico,代码行数:18,代码来源:x5_MainActivity.java
示例3: shouldOverrideUrlLoading
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(final WebView view, String url) {
LogUtils.i("Info", "mWebViewClient shouldOverrideUrlLoading:" + url);
//intent:// scheme的处理 如果返回false , 则交给 DefaultWebClient 处理 , 默认会打开该Activity , 如果Activity不存在则跳到应用市场上去. true 表示拦截
//例如优酷视频播放 ,intent://play?vid=XODEzMjU1MTI4&refer=&tuid=&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G9300%20Build%2FNRD90M%3B%20wv)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Version%2F4.0%20Chrome%2F58.0.3029.83%20Mobile%20Safari%2F537.36&source=exclusive-pageload&cookieid=14971464739049EJXvh|Z6i1re#Intent;scheme=youku;package=com.youku.phone;end;
//优酷想唤起自己应用播放该视频 , 下面拦截地址返回 true 则会在应用内 H5 播放 ,禁止优酷唤起播放该视频, 如果返回 false , DefaultWebClient 会根据intent 协议处理 该地址 , 首先匹配该应用存不存在 ,如果存在 , 唤起该应用播放 , 如果不存在 , 则跳到应用市场下载该应用 .
if (url.startsWith("intent://"))
return true;
else if (url.startsWith("youku"))
return true;
// else if(isAlipay(view,url)) //不需要,defaultWebClient内部会自动处理
// return true;
return false;
}
开发者ID:Justson,项目名称:AgentWebX5,代码行数:17,代码来源:AgentWebX5Fragment.java
示例4: handleLinked
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
private boolean handleLinked(String url) {
if (url.startsWith(android.webkit.WebView.SCHEME_TEL)
|| url.startsWith(SCHEME_SMS)
|| url.startsWith(android.webkit.WebView.SCHEME_MAILTO)
|| url.startsWith(android.webkit.WebView.SCHEME_GEO)) {
try {
Activity mActivity = null;
if ((mActivity = mWeakReference.get()) == null)
return false;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
mActivity.startActivity(intent);
} catch (ActivityNotFoundException ignored) {
if (AgentWebX5Config.DEBUG) {
ignored.printStackTrace();
}
}
return true;
}
return false;
}
开发者ID:Justson,项目名称:AgentWebX5,代码行数:22,代码来源:DefaultWebClient.java
示例5: onReceivedError
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
* The errorCode parameter corresponds to one of the ERROR_* constants.
*
* @param view The WebView that is initiating the callback.
* @param errorCode The error code corresponding to an ERROR_* value.
* @param description A String describing the error.
* @param failingUrl The url that failed to load.
*/
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Ignore error due to stopLoading().
if (!isCurrentlyLoading) {
return;
}
LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);
// If this is a "Protocol Not Supported" error, then revert to the previous
// page. If there was no previous page, then punt. The application's config
// is likely incorrect (start page set to sms: or something like that)
if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
parentEngine.client.clearLoadTimeoutTimer();
if (view.canGoBack()) {
view.goBack();
return;
} else {
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
开发者ID:jeremyup,项目名称:cordova-plugin-x5-webview,代码行数:33,代码来源:X5WebViewClient.java
示例6: onReceivedClientCertRequest
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* On received client cert request.
* The method forwards the request to any running plugins before using the default implementation.
*
* @param view
* @param request
*/
@Override
@TargetApi(21)
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
{
// Check if there is some plugin which can resolve this certificate request
PluginManager pluginManager = this.parentEngine.pluginManager;
if (pluginManager != null && pluginManager.onReceivedClientCertRequest(null, new X5CordovaClientCertRequest(request))) {
parentEngine.client.clearLoadTimeoutTimer();
return;
}
// By default pass to WebViewClient
super.onReceivedClientCertRequest(view, request);
}
开发者ID:Im-Kevin,项目名称:cordova.plugins.X5WebView,代码行数:23,代码来源:X5WebViewClient.java
示例7: onReceivedHttpAuthRequest
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* On received http auth request.
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
*/
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
// Get the authentication token (if specified)
AuthenticationToken token = this.getAuthenticationToken(host, realm);
if (token != null) {
handler.proceed(token.getUserName(), token.getPassword());
return;
}
// Check if there is some plugin which can resolve this auth challenge
PluginManager pluginManager = this.parentEngine.pluginManager;
if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(null, new X5CordovaHttpAuthHandler(handler), host, realm)) {
parentEngine.client.clearLoadTimeoutTimer();
return;
}
// By default handle 401 like we'd normally do!
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
开发者ID:runner525,项目名称:x5webview-cordova-plugin,代码行数:25,代码来源:X5WebViewClient.java
示例8: onJsPrompt
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Tell the client to display a prompt dialog to the user.
* If the client returns true, WebView will assume that the client will
* handle the prompt dialog and call the appropriate JsPromptResult method.
*
* Since we are hacking prompts for our own purposes, we should not be using them for
* this purpose, perhaps we should hack console.log to do this instead!
*/
@Override
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
// Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
if (handledRet != null) {
result.confirm(handledRet);
} else {
dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
@Override
public void gotResult(boolean success, String value) {
if (success) {
result.confirm(value);
} else {
result.cancel();
}
}
});
}
return true;
}
开发者ID:runner525,项目名称:x5webview-cordova-plugin,代码行数:29,代码来源:X5WebChromeClient.java
示例9: onJsPrompt
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Tell the client to display a prompt dialog to the user.
* If the client returns true, WebView will assume that the client will
* handle the prompt dialog and call the appropriate JsPromptResult method.
* <p>
* Since we are hacking prompts for our own purposes, we should not be using them for
* this purpose, perhaps we should hack console.log to do this instead!
*/
@Override
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
// Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
if (handledRet != null) {
result.confirm(handledRet);
} else {
dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
@Override
public void gotResult(boolean success, String value) {
if (success) {
result.confirm(value);
} else {
result.cancel();
}
}
});
}
return true;
}
开发者ID:zsxsoft,项目名称:cordova-plugin-x5-tbs,代码行数:29,代码来源:X5WebChromeClient.java
示例10: changGoForwardButton
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
private void changGoForwardButton(WebView view) {
if (view.canGoBack())
mBack.setAlpha(enable);
else
mBack.setAlpha(disable);
if (view.canGoForward())
mForward.setAlpha(enable);
else
mForward.setAlpha(disable);
if (view.getUrl() != null && view.getUrl().equalsIgnoreCase(mHomeUrl)) {
mHome.setAlpha(disable);
mHome.setEnabled(false);
} else {
mHome.setAlpha(enable);
mHome.setEnabled(true);
}
}
开发者ID:banwenmang,项目名称:X5web,代码行数:18,代码来源:BrowserActivity.java
示例11: onJsPrompt
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
try {
if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onJsPrompt", "public boolean " + ChromePath + ".onJsPrompt", WebView.class, String.class, String.class, String.class, JsPromptResult.class)) {
return super.onJsPrompt(view, url, message, defaultValue, result);
}
if (AgentWebX5Config.WEBVIEW_TYPE == AgentWebX5Config.WEBVIEW_AGENTWEB_SAFE_TYPE && mChromeClientCallbackManager != null && mChromeClientCallbackManager.getAgentWebCompatInterface() != null) {
LogUtils.i(TAG, "mChromeClientCallbackManager.getAgentWebCompatInterface():" + mChromeClientCallbackManager.getAgentWebCompatInterface());
if (mChromeClientCallbackManager.getAgentWebCompatInterface().onJsPrompt(view, url, message, defaultValue, result))
return true;
}
showJsPrompt(message, result, defaultValue);
} catch (Exception e) {
// e.printStackTrace();
}
return true;
}
开发者ID:Justson,项目名称:AgentWebX5,代码行数:23,代码来源:DefaultChromeClient.java
示例12: onReceivedSslError
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Notify the host application that an SSL error occurred while loading a resource.
* The host application must call either handler.cancel() or handler.proceed().
* Note that the decision may be retained for use in response to future SSL errors.
* The default behavior is to cancel the load.
*
* @param view The WebView that is initiating the callback.
* @param handler An SslErrorHandler object that will handle the user's response.
* @param error The SSL error object.
*/
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
final String packageName = parentEngine.cordova.getActivity().getPackageName();
final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();
ApplicationInfo appInfo;
try {
appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// debug = true
handler.proceed();
return;
} else {
// debug = false
super.onReceivedSslError(view, handler, error);
}
} catch (NameNotFoundException e) {
// When it doubt, lock it out!
super.onReceivedSslError(view, handler, error);
}
}
开发者ID:zsxsoft,项目名称:cordova-plugin-x5-tbs,代码行数:34,代码来源:X5WebViewClient.java
示例13: onPageFinished
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Notify the host application that a page has finished loading.
* This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
*
*
* @param view The webview initiating the callback.
* @param url The url of the page.
*/
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// Ignore excessive calls, if url is not about:blank (CB-8317).
if (!isCurrentlyLoading && !url.startsWith("about:")) {
return;
}
isCurrentlyLoading = false;
/**
* Because of a timing issue we need to clear this history in onPageFinished as well as
* onPageStarted. However we only want to do this if the doClearHistory boolean is set to
* true. You see when you load a url with a # in it which is common in jQuery applications
* onPageStared is not called. Clearing the history at that point would break jQuery apps.
*/
if (this.doClearHistory) {
view.clearHistory();
this.doClearHistory = false;
}
parentEngine.client.onPageFinishedLoading(url);
}
开发者ID:jeremyup,项目名称:cordova-plugin-x5-webview,代码行数:31,代码来源:X5WebViewClient.java
示例14: onPageFinished
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
/**
* Notify the host application that a page has finished loading.
* This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
*
* @param view The webview initiating the callback.
* @param url The url of the page.
*/
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// Ignore excessive calls, if url is not about:blank (CB-8317).
if (!isCurrentlyLoading && !url.startsWith("about:")) {
return;
}
isCurrentlyLoading = false;
/**
* Because of a timing issue we need to clear this history in onPageFinished as well as
* onPageStarted. However we only want to do this if the doClearHistory boolean is set to
* true. You see when you load a url with a # in it which is common in jQuery applications
* onPageStared is not called. Clearing the history at that point would break jQuery apps.
*/
if (this.doClearHistory) {
view.clearHistory();
this.doClearHistory = false;
}
parentEngine.client.onPageFinishedLoading(url);
}
开发者ID:zsxsoft,项目名称:cordova-plugin-x5-tbs,代码行数:30,代码来源:X5WebViewClient.java
示例15: shouldOverrideUrlLoading
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (mBizWebViewClient != null) {
return mBizWebViewClient.shouldOverrideUrlLoading(view, url);
}
return super.shouldOverrideUrlLoading(view, url);
}
开发者ID:snailycy,项目名称:AndroidHybridLib,代码行数:8,代码来源:X5WebViewClient.java
示例16: exposeJsInterface
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
// Bug being that Java Strings do not get converted to JS strings automatically.
// This isn't hard to work-around on the JS side, but it's easier to just
// use the prompt bridge instead.
return;
}
X5ExposedJsApi exposedJsApi = new X5ExposedJsApi(bridge);
webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}
开发者ID:jeremyup,项目名称:cordova-plugin-x5-webview,代码行数:12,代码来源:X5WebViewEngine.java
示例17: initWrapperWebView
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
private void initWrapperWebView(Context context) {
View contentView = LayoutInflater.from(context).inflate(R.layout.layout_wrapper_webview, this, true);
mWebView = new WebView(context);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
mWebView.setLayoutParams(layoutParams);
FrameLayout webviewContainer = (FrameLayout) contentView.findViewById(R.id.fl_webview_container);
webviewContainer.addView(mWebView, 0);
mProgressBar = (ProgressBar) contentView.findViewById(R.id.progress_bar);
mTitleTV = (TextView) contentView.findViewById(R.id.tv_title);
mTopNavigationBar = contentView.findViewById(R.id.rl_top_navigation_bar);
contentView.findViewById(R.id.btn_close).setOnClickListener(this);
contentView.findViewById(R.id.btn_refresh).setOnClickListener(this);
}
开发者ID:snailycy,项目名称:AndroidHybridLib,代码行数:15,代码来源:WrapperWebView.java
示例18: shouldInterceptRequest
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
try {
// Check the against the whitelist and lock out access to the WebView directory
// Changing this will cause problems for your application
if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
LOG.w(TAG, "URL blocked by whitelist: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
CordovaResourceApi resourceApi = parentEngine.resourceApi;
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
}
// If we don't need to special-case the request, let the browser load it.
return null;
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}
开发者ID:jeremyup,项目名称:cordova-plugin-x5-webview,代码行数:32,代码来源:X5WebViewClient.java
示例19: onShowFileChooser
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
uploadMessageAboveL = filePathCallback;
openImageChooserActivity();
return true;
}
开发者ID:stytooldex,项目名称:stynico,代码行数:8,代码来源:x5_MainActivity.java
示例20: onCreateWindow
import com.tencent.smtt.sdk.WebView; //导入依赖的package包/类
@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg)
{
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(view);
resultMsg.sendToTarget();
return true;
}
开发者ID:stytooldex,项目名称:stynico,代码行数:9,代码来源:x5_MainActivity.java
注:本文中的com.tencent.smtt.sdk.WebView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论