1

I am trying to load this popular podcast in an Android WebView:

http://www.stitcher.com/podcast/entrepreneuronfirecom/entrepreneur-on-fire-tim-ferriss-other-incredible-entrepreneurs

And this is how I render it:

public class PodcastsActivity extends BaseActivity  
{    
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        WebView webview = new WebView(this);
        webview.getSettings().setAppCacheEnabled(false);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.setInitialScale(100);
        webview.setWebViewClient(new WebViewClient());

        setContentView(webview);
        webview.loadUrl("http://www.stitcher.com/podcast/entrepreneuronfirecom/entrepreneur-on-fire-tim-ferriss-other-incredible-entrepreneurs");           

And in my manifest I have the activity defined like this:

    <activity
        android:name="PodcastsActivity"
        android:label="Podcasts" 
        android:hardwareAccelerated="true"/> 

But it renders like this:

enter image description here

Is there an extra setting that needs to be set? Or something I am missing?

Thanks!

Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
Genadinik
  • 18,153
  • 63
  • 185
  • 284

1 Answers1

6

I hope you have looked at other answers. Some of the things you may try are:

1) From webview not loading correctly in application question, you may try and enable java script before loading the URL:

webview.setInitialScale(1);
webview.getSettings().setAppCacheEnabled(false);
webview.getSettings().setJavaScriptEnabled(true);

2) As per Android webview not rendering html content correctly question, if your target is higher than 2.3.3 try adding this in your manifest file.

android:hardwareAccelerated="true"

Update

3) Also check that you have following permission in manifest as direct child to <manifest> tag:

<uses-permission android:name="android.permission.INTERNET" />

Unable to load webpage using WebView in Android

4) You can try shouldOverrideUrlLoading() method as stated here.

Update 2:

As you said that it displays correctly on your browser, there is another possibility of using the above method in case when a certain link is clicked within the app, it opens the default browser. I'm not sure if you would want this but it is a possibility. Something as follows:

webview.setWebViewClient(new WebViewClient(){
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url != null) {
            view.getContext().startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        } else {
            return false;
        }
    }
});

webview.loadUrl("http://www.stitcher.com/podcast/entrepreneuronfirecom/entrepreneur-on-fire-tim-ferriss-other-incredible-entrepreneurs");

Source: WebView link click open default browser

Hope this helps.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124