package edu.dianzhi.com.webviewdemo;
import android.Manifest;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.ValueCallback;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import org.xwalk.core.ClientCertRequest;
import org.xwalk.core.XWalkActivity;
import org.xwalk.core.XWalkHttpAuthHandler;
import org.xwalk.core.XWalkJavascriptResult;
import org.xwalk.core.XWalkResourceClient;
import org.xwalk.core.XWalkSettings;
import org.xwalk.core.XWalkUIClient;
import org.xwalk.core.XWalkView;
import org.xwalk.core.XWalkWebResourceRequest;
import org.xwalk.core.XWalkWebResourceResponse;
/**
* 作者:yangmo on 2016/10/22 09:06
* 邮箱:nmyangmo@126.com
*/
public class CrossWebViewPlayerActivity extends XWalkActivity {
private String mUrl;
private LinearLayout mLayout;
private XWalkView mWebView;
private NetReceiver netReceiver;
private PhoneCallReceiver phoneCallReceiver;
private boolean phoneCalling;
private EditText ed;
public XWalkView getmWebView() {
return mWebView;
}
public void setmWebView(XWalkView mWebView) {
this.mWebView = mWebView;
}
@Override
protected void onXWalkReady() {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mWebView = new XWalkView(getApplicationContext());
mWebView.setLayoutParams(params);
mLayout.addView(mWebView);
ed = (EditText) findViewById(R.id.ed_url_address);
//动态申请权限 读写权限,录音权限
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO},
3332);
} else {
//
mWebView.loadUrl(mUrl);
}
} else {
mWebView.loadUrl(mUrl);
}
XWalkSettings mWebSettings = mWebView.getSettings();
mWebSettings.setSupportZoom(true);//支持缩放
mWebSettings.setBuiltInZoomControls(true);//可以任意缩放
mWebSettings.setLoadWithOverviewMode(true);
mWebSettings.setUseWideViewPort(true);////将图片调整到适合webview的大小
// mWebSettings.setDefaultTextEncodingName("utf-8");
mWebSettings.setLoadsImagesAutomatically(true);
// mWebSettings.setMixedContentMode()
//调用JS方法.安卓版本大于17,加上注解 @JavascriptInterface
mWebSettings.setJavaScriptEnabled(true);//支持JS
// mWebView.clearCache(true);//清除缓存
// mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);//不使用缓存(使用:ebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK))
saveData(mWebSettings);
newWin(mWebSettings);
// setTitle("在线辅导");
mWebView.setResourceClient(new XWalkResourceClient(mWebView) {
//=========HTML5定位==========================================================
//需要先加入权限
//<uses-permission android:name="android.permission.INTERNET"/>
//<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
//<uses-permission android:name=
// "android.permission.ACCESS_COARSE_LOCATION"/>
@Override
public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedSslError(XWalkView view, ValueCallback<Boolean> callback, SslError error) {
// callback.onReceiveValue(false);
// super.onReceivedSslError(view, callback, error);
Toast.makeText(CrossWebViewPlayerActivity.this, "证书不合法", Toast.LENGTH_SHORT).show();
}
@Override
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
}
@Override
public void onLoadStarted(XWalkView view, String url) {
super.onLoadStarted(view, url);
}
@Override
public void onProgressChanged(XWalkView view, int progressInPercent) {
super.onProgressChanged(view, progressInPercent);
}
@Override
public void onReceivedClientCertRequest(XWalkView view, ClientCertRequest handler) {
super.onReceivedClientCertRequest(view, handler);
}
@Override
public void onDocumentLoadedInFrame(XWalkView view, long frameId) {
super.onDocumentLoadedInFrame(view, frameId);
}
@Override
public void onReceivedHttpAuthRequest(XWalkView view, XWalkHttpAuthHandler handler, String host, String realm) {
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
@Override
public void onReceivedLoadError(XWalkView view, int errorCode, String description, String failingUrl) {
super.onReceivedLoadError(view, errorCode, description, failing
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
WebViewDemo.rar (64个子文件)
WebViewDemo
gradlew.bat 2KB
gradlew 5KB
gradle.properties 872B
WebViewDemo.iml 942B
.gradle
2.8
taskArtifacts
fileHashes.bin 756KB
cache.properties.lock 17B
taskArtifacts.bin 223KB
fileSnapshots.bin 12.04MB
cache.properties 31B
outputFileStates.bin 25KB
app
proguard-rules.pro 670B
src
test
java
edu
dianzhi
com
webviewdemo
ExampleUnitTest.java 334B
androidTest
java
edu
dianzhi
com
webviewdemo
ApplicationTest.java 370B
main
res
mipmap-xxxhdpi
ic_launcher.png 10KB
drawable
mipmap-hdpi
ic_launcher.png 3KB
values
colors.xml 214B
strings.xml 163B
styles.xml 392B
dimens.xml 216B
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-mdpi
ic_launcher.png 2KB
mipmap-xhdpi
ic_launcher.png 5KB
teacher_160.png 11KB
ic_app_logo.png 13KB
layout
activity_main.xml 1KB
activity_choose.xml 1KB
values-w820dp
dimens.xml 364B
java
edu
dianzhi
com
webviewdemo
CrossWebViewPlayerActivity.java 16KB
MainActivity.java 12KB
ChooseActivity.java 1KB
MyApplication.java 336B
AndroidManifest.xml 2KB
app.iml 9KB
.gitignore 8B
build.gradle 746B
libs
crosswalk-23.53.589.4.aar 47.58MB
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 230B
.idea
gradle.xml 608B
runConfigurations.xml 564B
misc.xml 2KB
vcs.xml 164B
.name 11B
copyright
profiles_settings.xml 76B
modules.xml 359B
encodings.xml 159B
compiler.xml 686B
workspace.xml 217KB
libraries
crosswalk_23_53_589_4_.xml 393B
support_compat_24_2_0.xml 976B
support_vector_drawable_24_2_0.xml 648B
support_fragment_24_2_0.xml 990B
appcompat_v7_24_2_0.xml 769B
animated_vector_drawable_24_2_0.xml 653B
support_core_utils_24_2_0.xml 822B
support_v4_24_2_0.xml 420B
support_annotations_24_2_0.xml 511B
support_media_compat_24_2_0.xml 1018B
support_core_ui_24_2_0.xml 983B
.gitignore 105B
local.properties 512B
settings.gradle 14B
build
intermediates
dex-cache
cache.xml 7KB
build.gradle 521B
共 64 条
- 1
宏观与微观
- 粉丝: 35
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Javascript和Python的微商城项目设计源码 - MicroMall
- 基于Java的网上订餐系统设计源码 - online ordering system
- 基于Javascript的超级美眉网络资源管理应用模块设计源码
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论21