Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
pavel nganpi
Courses Plus Student 115 Pointswebview not displaying content for some urls. It opens up chrome browser
Hi Guys, for the blog reader app, the app work when i try to view the treehouse blog site inside of an activity as a webview. But when i try the itunes url or other websites, it doesnt show the content inside of my activity, instead it opens chrome. Now i dont know if this is normal or do i have to add some code for that, thanks. below is the code in the activity i am implementing the webview, thanks
package com.paveynganpi.applestorefeed;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
public class AppleFeedWebViewActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple_feed_web_view);
//get the intent from MainListActivity.java
Intent intent = getIntent();
Uri appleFeedUri = intent.getData();
WebView webView = (WebView)findViewById(R.id.webView);
webView.loadUrl(appleFeedUri.toString());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_apple_feed_web_view, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}