title: android - Making a ListView item open a URL in the browser?
body: <p>I'm building an RSS feed reader by following the example from this site: </p>
  
  <p><a href="https://www.androidpit.com/java-guide-2-program-your-own-rss-reader" rel="nofollow">https://www.androidpit.com/java-guide-2-program-your-own-rss-reader</a></p>
  
  <p>At the moment, when you click on a feed title, nothing happens. What I want it to do is to open the corresponding link in a browser but I've not been able to figure it out.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>private String readItem(XmlPullParser parser) throws XmlPullParserException, IOException {
              String result = null;
              parser.require(XmlPullParser.START_TAG, null, "item");
              while (parser.next() != XmlPullParser.END_TAG) {
                  if (parser.getEventType() != XmlPullParser.START_TAG) {
                      continue;
                  }
                  String name = parser.getName();
                  if (name.equals("title")) {
                      result = readTitle(parser);                 
                  } else {
                      skip(parser);
                  }
              } 
              return result;
          }
  
          // Processes link tags in the feed.
          private List&lt;String&gt; readLink(XmlPullParser parser) throws IOException, XmlPullParserException {
              ArrayList&lt;String&gt; link = new ArrayList&lt;&gt;();
              parser.require(XmlPullParser.START_TAG, null, "link");
              link.add(readText(parser));
              parser.require(XmlPullParser.END_TAG, null, "link");
              return link;
          }
  
          // Processes title tags in the feed.
          private String readTitle(XmlPullParser parser) throws IOException, XmlPullParserException {
              parser.require(XmlPullParser.START_TAG, null, "title");
              String title = readText(parser);
              parser.require(XmlPullParser.END_TAG, null, "title");
              return title;
          }
  </code></pre>
  
  <p>I end up with a warning that says the method readLink is never used locally. I'm not sure whether I should alter the readItem method because there is a readChannel method that requires the value that is returned to be a string. </p>
  
  <p>When I use <code>public void onListItemClick(ListView l, View v, int position, long id) {
              super.onListItemClick(l, v, position, id); ... }</code> with a Toast, I'm able to see the position of the Item that was clicked but when I use this the app crashes.</p>
  
  <pre><code>        Uri uri = Uri.parse(link.get(position));
          Intent intent = new Intent(Intent.ACTION_VIEW, uri);
          startActivity(intent);
  </code></pre>
  
  <p>So my question is: how do I make a browser open that goes to the corresponding title's link? I'm very new with java and android development so please bear with me.</p>
  
  <p>P.S I've already set my ListView as clickable.</p>