I have an app, which parses RSS feed into list, and when we click on the item of the list it calls the other activity to display in WebView the content inside rss feed link:
public class ListListener implements OnItemClickListener {
// List item's reference
List<RssItem> listItems;
// Calling activity reference
Activity activity;
public ListListener(List<RssItem> aListItems, Activity anActivity) {
listItems = aListItems;
activity = anActivity;
}
/**
* Start a browser with url from the rss item.
*/
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
//Intent i = new Intent(Intent.ACTION_VIEW);
//i.setData(Uri.parse(listItems.get(pos).getLink()));
Intent i = new Intent(activity, WebPageActivity.class);
i.putExtra("LINK", Uri.parse(listItems.get(pos).getLink()));
//Intent intent = new Intent(this, WebPageController(listItems.get(pos).getLink()));
activity.startActivity(i);
}
}
And from onItemClick it supposed to call that WebView activity to display the webpage
public class WebPageActivity extends ActionBarActivity {
private WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String url = intent.getStringExtra("LINK");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_page);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web_page, 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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
There is no mistakes in compilation, but when I click in the app to go on WebPage activity it stops. Here is my logcat http://pastie.org/9606345