views:

419

answers:

3

I'm trying to load the parsed html data from an rss feed using a WebView, but the webview claims that the page:

"data:text/html;utf-8,[The html I'm trying to display]"

is not available.

alt text

I find it strange that it seems to be putting the html data into the url, when I just want it to display it.

Here's my code right now for the webview:

Bundle data = getIntent().getExtras();

WebView webview = new WebView(this);
setContentView(webview);

webview.loadData(data.getString("DEFAULTTEXT"), "text/html", "utf-8");

Where the HTML has been passed in a string in the Bundle with the identifier: DEFAULTTEXT. I've tested the class and the HTML is passed fine, it just isn't displayed correctly.

It works fine on some of the webpages I've tried, but not others. I'll try to post the code of one that works and one that doesn't.

Thanks.

A: 

Are you sure you have the correct permissions defined in the manifest.xml?

Faisal Abid
I have internet permissions, audio state, and phone state is there another one I'd need?
GuyNoir
A: 

Huuu.... so I turned my computer on this morning and it worked perfectly. I still don't know what the problem was. :/

Edit: Never mind. It works on some, but not all of the pages I try to display.

Edit2: swapping it out for loadDataWithBaseURL worked like a charm.

GuyNoir
Proboly a glitch in the emulator. Glad it worked
Faisal Abid
Oh wait, it works on half of the webpages I try to display. Arg..
GuyNoir
Mine worked across the board and then stopped working for everything one day. loadDataWithBaseURL works for now, hope it doesn't break as mysteriously
Martyn
A: 

I believe this sporadic behavior of loadData* is because of what is the content of the page you are trying to load. If it is plain simple html it has no problem. But if it has components like css or other features requiring external info, it will bail out. My experience!

Reza Nezami