[android-developers] Re: WebView loadData and XML Parsing Question
I have to display html content which i get from am xml(RSS feed).I am using the loadDataWithBaseURL . But if the the html content contains an image,how do i render the image in the webview as in the html content. webView.loadDataWithBaseURL(www.company.com,descHtmlString, text/ html, utf-8, www.companyfailed.com); On Jan 13, 1:30 pm, Ryan ryankelly...@hotmail.com wrote: I'm guessing it was the first suggestion, not the other two. Actually, they were such simple changes I made both at once. E.G. I used UTF-8, instead of utf-8. And I switched to the loadDataWithBaseURL function. The variable html was always a String so no change there. I'm guessing it's the loadDataWithBaseURL function that did the trick, but I will try both suggestions in isolation just to make sure. I'd rather not use the loadDataWithBaseURL to load local data if I can help it, so I'll continue researching a fix for the loadData function. Thanks for your help. On Jan 12, 10:42 pm, Mark Murphy mmur...@commonsware.com wrote: Ryan wrote: Wow.. thanks Mark, that fixed it! I'm guessing it was the first suggestion, not the other two. Do you know why that works, seems an odd way to get it to work?? It is definitely odd. However, it seems to cure a lot of ills, ills that I presume come from some issues with the implementation of the simpler loadData() method. I need to look at the source for that sometime... -- Mark Murphy (a Commons Guy)http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
I am trying to show a html string such as sample3 =a href=\www.google.com\Link text/aimg src= http://www.isical.ac.in/~clia/images/google_logo.jpg; webView.loadDataWithBaseURL(www.company.com,sample3 , text/html, utf-8, www.companyfailed.com); When this webview is displayed then i am not able to see the image in the sample3 string. How do i acheive that? On Thu, Feb 19, 2009 at 3:01 PM, forandroid forandr...@gmail.com wrote: I have to display html content which i get from am xml(RSS feed).I am using the loadDataWithBaseURL . But if the the html content contains an image,how do i render the image in the webview as in the html content. webView.loadDataWithBaseURL(www.company.com,descHtmlString, text/ html, utf-8, www.companyfailed.com); On Jan 13, 1:30 pm, Ryan ryankelly...@hotmail.com wrote: I'm guessing it was the first suggestion, not the other two. Actually, they were such simple changes I made both at once. E.G. I used UTF-8, instead of utf-8. And I switched to the loadDataWithBaseURL function. The variable html was always a String so no change there. I'm guessing it's the loadDataWithBaseURL function that did the trick, but I will try both suggestions in isolation just to make sure. I'd rather not use the loadDataWithBaseURL to load local data if I can help it, so I'll continue researching a fix for the loadData function. Thanks for your help. On Jan 12, 10:42 pm, Mark Murphy mmur...@commonsware.com wrote: Ryan wrote: Wow.. thanks Mark, that fixed it! I'm guessing it was the first suggestion, not the other two. Do you know why that works, seems an odd way to get it to work?? It is definitely odd. However, it seems to cure a lot of ills, ills that I presume come from some issues with the implementation of the simpler loadData() method. I need to look at the source for that sometime... -- Mark Murphy (a Commons Guy)http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
I'm guessing it was the first suggestion, not the other two. Actually, they were such simple changes I made both at once. E.G. I used UTF-8, instead of utf-8. And I switched to the loadDataWithBaseURL function. The variable html was always a String so no change there. I'm guessing it's the loadDataWithBaseURL function that did the trick, but I will try both suggestions in isolation just to make sure. I'd rather not use the loadDataWithBaseURL to load local data if I can help it, so I'll continue researching a fix for the loadData function. Thanks for your help. On Jan 12, 10:42 pm, Mark Murphy mmur...@commonsware.com wrote: Ryan wrote: Wow.. thanks Mark, that fixed it! I'm guessing it was the first suggestion, not the other two. Do you know why that works, seems an odd way to get it to work?? It is definitely odd. However, it seems to cure a lot of ills, ills that I presume come from some issues with the implementation of the simpler loadData() method. I need to look at the source for that sometime... -- Mark Murphy (a Commons Guy)http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Ryan launch app run using debugger in Eclipse and post the debug log.. Several of us are developing apps using Webview, I am and several others so the better feedback we can give each other via this list and others helps lift all our webview skills at once :) On Jan 12, 3:19 pm, Ryan ryankelly...@hotmail.com wrote: Hi, When I use the WebView.loadData function from a sring returned from XMLPullParser.nextText, the WebView always displays the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. However, if I hard code the same text into the loadData function all appears fine. My code for parsing the XML is very similar to the api example, which I have copied below:- public String getHTMLDescription(InputStream xmlData) throws XmlPullParserException, IOException { String html = new String(); InputStreamReader reader = new InputStreamReader(xmlData, UTF-8); BufferedReader buffer = new BufferedReader(reader); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(buffer); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_TAG) { if(xpp.getName().compareTo(description) == 0) { html = xpp.nextText(); } eventType = xpp.next(); } return html; } Any ideas? Thanks, Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Thanks for your reply Fred. The debug log shows the follwing line for getting the text out with the xpp.next() function. 01-12 21:53:48.705: INFO/System.out(549): Text BRBTonight's weather in London/BBRA few evening showers Min 6C(43F ) BRProbability of rain: 89%BRMinimum Temperature: 6C(43F )BRWind force Beaufort: 4BRWind description: Moderate BreezeBRWind direction: SSWBRSunset at: 4:17 pm The log then shows:- 01-12 21:53:49.544: INFO/ActivityManager(51): Displayed activity com.mycom.myapp/.MyWebViewActivity: 5050 ms It is this activity that has a WebView that calls the loadData function with the string above. There are no errors as such. It's as if the WebView takes the string as a URL and try's to request data from the URL, instead of just displaying the string. Does that make sense? On Jan 12, 9:34 pm, Fred Grott(shareme) fred.gr...@gmail.com wrote: Ryan launch app run using debugger in Eclipse and post the debug log.. Several of us are developing apps using Webview, I am and several others so the better feedback we can give each other via this list and others helps lift all our webview skills at once :) On Jan 12, 3:19 pm, Ryan ryankelly...@hotmail.com wrote: Hi, When I use the WebView.loadData function from a sring returned from XMLPullParser.nextText, the WebView always displays the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. However, if I hard code the same text into the loadData function all appears fine. My code for parsing the XML is very similar to the api example, which I have copied below:- public String getHTMLDescription(InputStream xmlData) throws XmlPullParserException, IOException { String html = new String(); InputStreamReader reader = new InputStreamReader(xmlData, UTF-8); BufferedReader buffer = new BufferedReader(reader); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(buffer); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_TAG) { if(xpp.getName().compareTo(description) == 0) { html = xpp.nextText(); } eventType = xpp.next(); } return html; } Any ideas? Thanks, Ryan- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Actually, I think I am confusing the issue. I just tried the following code inside my WebView:- final String mimeType = text/html; final String encoding = utf-8; html = BRBTonight's weather in London/BBRA few evening showers Min 6C(43F )BRProbability of rain: 89%BRMinimum Temperature: 6C(43F )BRWind force Beaufort: 4BRWind description: Moderate BreezeBRWind direction: SSWBRSunset at: 4:17 pm; this.loadData(html, mimeType, encoding); This does not do wha I expect. This displays a WebView with the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. I was expecting the WebView to use my string as the HTML content. This is how it works for simpler strings. On Jan 12, 9:59 pm, Ryan ryankelly...@hotmail.com wrote: Thanks for your reply Fred. The debug log shows the follwing line for getting the text out with the xpp.next() function. 01-12 21:53:48.705: INFO/System.out(549): Text BRBTonight's weather in London/BBRA few evening showers Min 6C(43F ) BRProbability of rain: 89%BRMinimum Temperature: 6C(43F )BRWind force Beaufort: 4BRWind description: Moderate BreezeBRWind direction: SSWBRSunset at: 4:17 pm The log then shows:- 01-12 21:53:49.544: INFO/ActivityManager(51): Displayed activity com.mycom.myapp/.MyWebViewActivity: 5050 ms It is this activity that has a WebView that calls the loadData function with the string above. There are no errors as such. It's as if the WebView takes the string as a URL and try's to request data from the URL, instead of just displaying the string. Does that make sense? On Jan 12, 9:34 pm, Fred Grott(shareme) fred.gr...@gmail.com wrote: Ryan launch app run using debugger in Eclipse and post the debug log.. Several of us are developing apps using Webview, I am and several others so the better feedback we can give each other via this list and others helps lift all our webview skills at once :) On Jan 12, 3:19 pm, Ryan ryankelly...@hotmail.com wrote: Hi, When I use the WebView.loadData function from a sring returned from XMLPullParser.nextText, the WebView always displays the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. However, if I hard code the same text into the loadData function all appears fine. My code for parsing the XML is very similar to the api example, which I have copied below:- public String getHTMLDescription(InputStream xmlData) throws XmlPullParserException, IOException { String html = new String(); InputStreamReader reader = new InputStreamReader(xmlData, UTF-8); BufferedReader buffer = new BufferedReader(reader); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(buffer); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_TAG) { if(xpp.getName().compareTo(description) == 0) { html = xpp.nextText(); } eventType = xpp.next(); } return html; } Any ideas? Thanks, Ryan- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Ryan wrote: Actually, I think I am confusing the issue. I just tried the following code inside my WebView:- final String mimeType = text/html; final String encoding = utf-8; html = BRBTonight's weather in London/BBRA few evening showers Min 6C(43F )BRProbability of rain: 89%BRMinimum Temperature: 6C(43F )BRWind force Beaufort: 4BRWind description: Moderate BreezeBRWind direction: SSWBRSunset at: 4:17 pm; this.loadData(html, mimeType, encoding); This does not do wha I expect. This displays a WebView with the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. I was expecting the WebView to use my string as the HTML content. This is how it works for simpler strings. Try loadDataWithBaseURL(), even if you have to supply a garbage URL as the base (e.g., fake://oh.this.is.so.not.real). Also, try UTF-8 instead of utf-8. Also also, the html variable is a String, and not something else, right? -- Mark Murphy (a Commons Guy) http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Wow.. thanks Mark, that fixed it! Do you know why that works, seems an odd way to get it to work?? On Jan 12, 10:10 pm, Mark Murphy mmur...@commonsware.com wrote: Ryan wrote: Actually, I think I am confusing the issue. I just tried the following code inside my WebView:- final String mimeType = text/html; final String encoding = utf-8; html = BRBTonight's weather in London/BBRA few evening showers Min 6C(43F )BRProbability of rain: 89%BRMinimum Temperature: 6C(43F )BRWind force Beaufort: 4BRWind description: Moderate BreezeBRWind direction: SSWBRSunset at: 4:17 pm; this.loadData(html, mimeType, encoding); This does not do wha I expect. This displays a WebView with the following error message:- Web page not available The Web page at data:text/html;utf-8... might be temporarily down.. I was expecting the WebView to use my string as the HTML content. This is how it works for simpler strings. Try loadDataWithBaseURL(), even if you have to supply a garbage URL as the base (e.g., fake://oh.this.is.so.not.real). Also, try UTF-8 instead of utf-8. Also also, the html variable is a String, and not something else, right? -- Mark Murphy (a Commons Guy)http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published!- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView loadData and XML Parsing Question
Ryan wrote: Wow.. thanks Mark, that fixed it! I'm guessing it was the first suggestion, not the other two. Do you know why that works, seems an odd way to get it to work?? It is definitely odd. However, it seems to cure a lot of ills, ills that I presume come from some issues with the implementation of the simpler loadData() method. I need to look at the source for that sometime... -- Mark Murphy (a Commons Guy) http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---