广告显示在蜂窝web视图而不是ICS网页视图 [英] Ads Showing on HoneyComb Webview but Not ICS Webview

查看:657
本文介绍了广告显示在蜂窝web视图而不是ICS网页视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经调整了我的蜂窝应用程序在ICS工作。一切都很好,除了我在web视图不再显示广告。我并没有code更改此区段。该ICS兼容code显示了一个蜂窝设备上,但不是ICS设备上的广告。什么是不同的,我该如何处理?

下面是我收到ICS设备上的日志,而不是蜂窝或更低:

  14 03-08:50:42.485:W /的WebView(24262):java.lang.Throwable中:警告:的WebView方法被调用线程上的主题-617。所有的WebView方法必须在UI线程调用。的WebView的未来版本可能不支持在其他线程使用。
03-08 14:50:42.485:W /的WebView(24262):在android.webkit.WebView.checkThread(WebView.java:9468)
03-08 14:50:42.485:W /的WebView(24262):在android.webkit.WebView.getSettings(WebView.java:4143)
03-08 14:50:42.485:W /的WebView(24262):在com.accuweather.android.tablet.ads.AdView $ 2.run(AdView.java:160)
03-08 14:50:42.495:W / System.err的(24262):java.io.IOException异常:java.net.URISyntaxException:无效%的序列:查询%WL索引138: http://www.accuweather.com/adrequest/adrequest.asmx/getAd$c$c?strAppID=lenovo&strPartner$c$c=lenovo&strIpAddress=fe80::42fc:89ff:fe93:9fcb%wlan0&strUserAgent=Mozilla%2F5.0+%28Linux%3B+U%3B+Android+4.0.3%3B+en-us%3B+Xoom+Build%2FIML77%29+AppleWebKit%2F534.30+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Safari%2F534.30&strCurrentZip$c$c=cityId=335315&strWeatherIcon=12&strUUID=99000052310400
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.http.HttpEngine<&初始化GT;(HttpEngine.java:194)
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.http.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:256)
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.http.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:243)
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:78)
03-08 14:50:42.495:W / System.err的(24262):在com.accuweather.android.tablet.ads.AdView $ AdRequest.getInputStreamFromURL(AdView.java:345)
03-08 14:50:42.495:W / System.err的(24262):在com.accuweather.android.tablet.ads.AdView $ AdRequest.makeRequest(AdView.java:293)
03-08 14:50:42.495:W / System.err的(24262):在com.accuweather.android.tablet.ads.AdView $ 2.run(AdView.java:159)
03-08 14:50:42.495:W / System.err的(24262):在指数138查询%WL:java.net.URISyntaxException:无效%的序列产生的原因: http://www.accuweather.com/adrequest/adrequest.asmx/getAd$c$c?strAppID=lenovo&strPartner$c$c=lenovo&strIpAddress=fe80::42fc:89ff:fe93:9fcb%wlan0&strUserAgent=Mozilla%2F5.0+%28Linux%3B+U%3B+Android+4.0.3%3B+en-us%3B+Xoom+Build%2FIML77%29+AppleWebKit%2F534.30+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Safari%2F534.30&strCurrentZip$c$c=cityId=335315&strWeatherIcon=12&strUUID=99000052310400
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.Uri codec.validate(URI codec.java:58)
03-08 14:50:42.495:W / System.err的(24262):在java.net.URI.parseURI(URI.java:406)
03-08 14:50:42.495:W / System.err的(24262):在java.net.URI中的<&初始化GT;(URI.java:204)
03-08 14:50:42.495:W / System.err的(24262):在java.net.URL.toURILenient(URL.java:510)
03-08 14:50:42.495:W / System.err的(24262):在libcore.net.http.HttpEngine<&初始化GT;(HttpEngine.java:192)
03-08 14:50:42.495:W / System.err的(24262):... 6个


解决方案

的ICS的WebView实现了改组,所以我们很多人有与pre-ICS和ICS的WebView行为问题。

看起来你有两个问题。

首先,你要带code您的查询,因为它看起来像你不能将它在HTML中的特殊意义逃脱的%。它看起来像它在strIpAddress参数发生。你可以用code是这样的:

 字符串连接codedIPAddress = URLEn coder.en code(strIpAddressValue);

我会带code各参数值,然后把这些一起到使用的String.format或只是字符串+最终URL字符串。这样,你会避免未来类似的问题。

二,Android是抱怨,你不是要求从UI线程的WebView。我想换行的方法(我假设你调用它showAd()),您在runInUiThread呼吁像这样:

  activity.runOnUiThread(新的Runnable(){
   公共无效的run(){
      webView.showAd();
   }
});

I have tweaked my Honeycomb application to work on ICS. All is well EXCEPT my ads in the webview no longer display. I have made no code changes to this section. The ICS compatible code shows ads on a HoneyComb device but not on an ICS device. What is different and how do I handle?

Here are logs that I receive on ICS device, but not HoneyComb or lower:

03-08 14:50:42.485: W/webview(24262): java.lang.Throwable: Warning: A WebView method was called on thread 'Thread-617'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
03-08 14:50:42.485: W/webview(24262):   at android.webkit.WebView.checkThread(WebView.java:9468)
03-08 14:50:42.485: W/webview(24262):   at android.webkit.WebView.getSettings(WebView.java:4143)
03-08 14:50:42.485: W/webview(24262):   at com.accuweather.android.tablet.ads.AdView$2.run(AdView.java:160)
03-08 14:50:42.495: W/System.err(24262): java.io.IOException: java.net.URISyntaxException: Invalid % sequence: %wl in query at index 138: http://www.accuweather.com/adrequest/adrequest.asmx/getAdCode?strAppID=lenovo&strPartnerCode=lenovo&strIpAddress=fe80::42fc:89ff:fe93:9fcb%wlan0&strUserAgent=Mozilla%2F5.0+%28Linux%3B+U%3B+Android+4.0.3%3B+en-us%3B+Xoom+Build%2FIML77%29+AppleWebKit%2F534.30+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Safari%2F534.30&strCurrentZipCode=cityId=335315&strWeatherIcon=12&strUUID=99000052310400
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.http.HttpEngine.<init>(HttpEngine.java:194)
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.http.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:256)
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.http.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:243)
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:78)
03-08 14:50:42.495: W/System.err(24262):    at com.accuweather.android.tablet.ads.AdView$AdRequest.getInputStreamFromURL(AdView.java:345)
03-08 14:50:42.495: W/System.err(24262):    at com.accuweather.android.tablet.ads.AdView$AdRequest.makeRequest(AdView.java:293)
03-08 14:50:42.495: W/System.err(24262):    at com.accuweather.android.tablet.ads.AdView$2.run(AdView.java:159)
03-08 14:50:42.495: W/System.err(24262): Caused by: java.net.URISyntaxException: Invalid % sequence: %wl in query at index 138: http://www.accuweather.com/adrequest/adrequest.asmx/getAdCode?strAppID=lenovo&strPartnerCode=lenovo&strIpAddress=fe80::42fc:89ff:fe93:9fcb%wlan0&strUserAgent=Mozilla%2F5.0+%28Linux%3B+U%3B+Android+4.0.3%3B+en-us%3B+Xoom+Build%2FIML77%29+AppleWebKit%2F534.30+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Safari%2F534.30&strCurrentZipCode=cityId=335315&strWeatherIcon=12&strUUID=99000052310400
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.UriCodec.validate(UriCodec.java:58)
03-08 14:50:42.495: W/System.err(24262):    at java.net.URI.parseURI(URI.java:406)
03-08 14:50:42.495: W/System.err(24262):    at java.net.URI.<init>(URI.java:204)
03-08 14:50:42.495: W/System.err(24262):    at java.net.URL.toURILenient(URL.java:510)
03-08 14:50:42.495: W/System.err(24262):    at libcore.net.http.HttpEngine.<init>(HttpEngine.java:192)
03-08 14:50:42.495: W/System.err(24262):    ... 6 more

解决方案

The ICS WebView implementation was revamped, so a lot of us are having issues with pre-ICS and ICS WebView behavior.

It looks like you have two problems.

First, you want to encode your query, as it looks like you can't pass that "%" which has a special meaning in HTML escaping. It looks like it is happening in the strIpAddress parameter. You can use code like this:

String encodedIPAddress = URLEncoder.encode(strIpAddressValue);

I would encode each parameter value, then put those all together into your final URL String using String.format or just String +. This way you'll avoid any future similar problems.

Second, Android is complaining that you're not calling the WebView from a UI thread. I would wrap the method (I'm assuming you're calling it showAd()) that you are calling in runInUiThread like so:

activity.runOnUiThread(new Runnable() {
   public void run() {
      webView.showAd();
   }
});

这篇关于广告显示在蜂窝web视图而不是ICS网页视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆