当前位置: 首页 > news >正文

上海电商设计招聘网站/整站优化的公司

上海电商设计招聘网站,整站优化的公司,免费制作图片带字软件,php网站开发班我面临有关在5.0(lollipop)以下的android中加载网址的问题加载数据太慢,但是在android 5.0或更高版本中可以正常工作.如何解决这个问题?I have follow this link.&How to improve webview load time我的代码是SuppressLint({ "SetJavaScriptEnabled",…

我面临有关在5.0(lollipop)以下的android中加载网址的问题

加载数据太慢,但是在android 5.0或更高版本中可以正常工作.如何解决这个问题?

I have follow this link.

&

How to improve webview load time

我的代码是

@SuppressLint({ "SetJavaScriptEnabled", "DefaultLocale" })

public class YS_WebViewActivity extends Activity

{

private Button btnDone;

private WebView webViewLoadUrl;

private YS_GeneralUtility generalUtility;

private Dialog alertDialogBox;

private String url = "";

private TextView tvLoading;

private Button btnCancel;

private Button btnRetry;

@SuppressLint("InlinedApi")

@SuppressWarnings("deprecation")

@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_webview);

btnDone = (Button) findViewById(R.id.btnDone);

webViewLoadUrl = (WebView) findViewById(R.id.webViewLoadUrl);

//webViewLoadUrl.setBackgroundColor(Color.parseColor("#123456"));

tvLoading = (TextView) findViewById(R.id.tvLoading);

url = getIntent().getExtras().getString("url");

webViewLoadUrl.setVisibility(View.INVISIBLE);

generalUtility = new YS_GeneralUtility(this);

webViewLoadUrl.getSettings().setJavaScriptEnabled(true); // enable javascript

try {

webViewLoadUrl.getSettings().setRenderPriority(RenderPriority.HIGH);

webViewLoadUrl.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

webViewLoadUrl.getSettings().setDomStorageEnabled(true);

webViewLoadUrl.getSettings().setAllowFileAccess(true);

webViewLoadUrl.getSettings().setAllowContentAccess(true);

webViewLoadUrl.getSettings().setAllowFileAccessFromFileURLs(true);

//webViewLoadUrl.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);

} catch (Exception e) {

e.printStackTrace();

}

tvLoading.setTypeface(generalUtility.faceAvenirLight);

btnDone.setTypeface(generalUtility.faceAvenirMedium);

btnDone.setOnClickListener(new OnClickListener()

{

@Override

public void onClick(View v)

{

myErrorFinish();

}

});

webViewLoadUrl.setWebViewClient(new WebViewClient()

{

public boolean shouldOverrideUrlLoading(WebView view, String url)

{

//Log.i(TAG, "Processing webview url click...");

view.loadUrl(url);

return true;

}

public void onPageFinished(WebView view, String url)

{

//Log.i(TAG, "Finished loading URL: " + url);

webViewLoadUrl.setVisibility(View.VISIBLE);

tvLoading.setVisibility(View.INVISIBLE);

}

String errorData = "

"

+ "

"

+ "

+ "";

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)

{

// Log.e(TAG, failingUrl + "Error: " + description);

view.loadData(errorData, "text/html", "UTF-8");

alertDialogOnInternetOff(getString(R.string.errorMsgInternet));

// finish();

}

@Override

public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

super.onReceivedSslError(view, handler, error);

handler.proceed();

}

});

webViewLoadUrl.loadUrl(url);

// setContentView(webview);

}

private void alertDialogOnInternetOff(String message)

{

alertDialogBox = new Dialog(YS_WebViewActivity.this, R.style.InternetErrorPopup);

alertDialogBox.requestWindowFeature(Window.FEATURE_NO_TITLE);

alertDialogBox.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

alertDialogBox.setContentView(R.layout.internetpopup_dialog);

alertDialogBox.setCancelable(false);

alertDialogBox.show();

btnCancel = (Button) alertDialogBox.findViewById(R.id.btnCancel);

btnRetry = (Button) alertDialogBox.findViewById(R.id.btnRetry);

TextView txtExitMessage = (TextView) alertDialogBox.findViewById(R.id.textViewMessage);

TextView horizontalLinePopup = (TextView) alertDialogBox.findViewById(R.id.horizontalLinePopup);

TextView verticalLinePopup = (TextView) alertDialogBox.findViewById(R.id.verticalLinePopup);

horizontalLinePopup.setBackgroundColor(getResources().getColor(R.color.internetpopupBorderinnerpageColor));

verticalLinePopup.setBackgroundColor(getResources().getColor(R.color.internetpopupBorderinnerpageColor));

txtExitMessage.setTypeface(generalUtility.faceAvenirLight);

btnCancel.setTypeface(generalUtility.faceAvenirLight);

btnRetry.setTypeface(generalUtility.faceAvenirLight);

txtExitMessage.setText(R.string.errorMsgInternet);

btnCancel.setText(R.string.cancel);

btnRetry.setText(R.string.retry);

alertDialogBox.setCancelable(false);

btnCancel.setOnClickListener(new OnClickListener()

{

@Override

public void onClick(View v)

{

alertDialogBox.dismiss();

Log.d("AlertDialog", "Negative");

YS_WebViewActivity.this.finish();

}

});

btnRetry.setOnClickListener(new OnClickListener()

{

@Override

public void onClick(View v)

{

alertDialogBox.dismiss();

Log.d("AlertDialog", "Positive");

tvLoading.setVisibility(View.VISIBLE);

webViewLoadUrl.loadUrl(url);

}

});

}

private void myErrorFinish()

{

/*

* Jump to the Setting Screen on pressing back button of device

*/

YS_WebViewActivity.this.finish();

//overridePendingTransition(R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_bottom);

}

@Override

public void onBackPressed()

{

myErrorFinish();

super.onBackPressed();

}

}

这是XML …

android:id="@+id/RelativeLayout1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/listback"

android:orientation="vertical" >

android:id="@+id/textView"

android:layout_width="match_parent"

android:layout_height="42dip"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:background="@drawable/navigationbackground" />

android:id="@+id/btnDone"

android:layout_width="wrap_content"

android:layout_height="42dip"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentTop="true"

android:background="@android:color/transparent"

android:text="@string/done"

android:textColor="@android:color/white"

android:textSize="17sp" />

android:id="@+id/webViewLoadUrl"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_below="@id/btnDone"

android:layout_centerVertical="true" />

android:id="@+id/tvLoading"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:gravity="center"

android:text="@string/loading"

android:textColor="@android:color/white"

android:textSize="18sp" />

解决方法:

如果在所有其他答案之后您的问题仍然存在,则需要测试URL /服务器响应和数据格式.

标签:webview,android-webview,android

来源: https://codeday.me/bug/20191119/2038627.html

http://www.jmfq.cn/news/4893607.html

相关文章:

  • 网站后台管理系统素材/快速排名推荐
  • 做网站关键词要懂代码么/哪里做网站便宜
  • 海口企业自助建站/重庆森林经典台词 凤梨罐头
  • 手机免费建设网站/网络营销成功的品牌
  • 做问卷不花钱的网站/网络推广培训课程内容
  • 建立网站需要多久/如何制作网站赚钱
  • 做网站最专业的公司/百度浏览器下载官方免费
  • 手机企业网站怎么做/关键词优化技巧有哪些
  • 淄博专业网站建设价格/怎么关闭seo综合查询
  • 冀州建设局网站/网站点击量统计
  • 尚义网站建设wl17581/刚刚刚刚刚刚好痛
  • 北京国际建设集团网站/百度搜索指数排名
  • 网站建设费专用发票能不能抵扣/百度一下官网首页百度一下
  • 安阳哪里做360网站/推广游戏怎么拉人最快
  • 济南地铁建设/seo教程技术优化搜索引擎
  • 做淘宝优惠券网站要多少钱/数据平台
  • 网站建设私单合同/emlog友情链接代码
  • 威海网站建设短信精准群发/今日百度关键词排名
  • 建设部建造师强制注销网站/android优化大师
  • 如何查网站是织梦做的/企业邮箱哪个好
  • 我的网站域名是什么/社群运营的经典案例
  • 国内创意产品网站/营销网络是什么
  • 连云港建设网站/搜索引擎有哪些软件
  • 免费注册网站哪个好/路由优化大师
  • 装修网网站建设/北京seo加盟
  • 南京网页网站制作/常见的搜索引擎
  • 福州cms建站/网络营销方案的制定
  • 网络存储上做网站/如何申请网站域名流程
  • 传奇公益服/浙江关键词优化
  • 能免费做微信群推广的网站/十大seo公司