title: Android Studio: RSS reader with xml
body: <p>I am trying to create an RSS reader from an xml file.</p>
  
  <p>Most of my code is built off of this template: <a href="http://www.tutorialspoint.com/android/android_rss_reader.htm" rel="nofollow">http://www.tutorialspoint.com/android/android_rss_reader.htm</a></p>
  
  <p>I modified the code for my overall goal. The goal is to create a RSS feed with in a web based mobile application.</p>
  
  <p>The problem is the app can not pull the rss feed properly. I get a statement saying your url can not be found.</p>
  
  <p>Any help is much appreciated.</p>
  
  <p>Activity Main</p>
  
  <pre><code>&lt;TextView android:text="RSS example" android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/textview"
      android:textSize="35dp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true" /&gt;
  
  
  &lt;EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/editText"
      android:layout_below="@+id/textview"
      android:hint="Link"
      android:textColorHint="#ff69ff0e"
      android:layout_alignParentRight="true"
      android:layout_alignParentEnd="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
  
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Result"
      android:id="@+id/button2"
  
      android:layout_alignRight="@+id/editText"
      android:layout_alignEnd="@+id/editText" /&gt;
  </code></pre>
  
  <p>Second Activity</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;WebView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/webView"
      android:layout_gravity="center_horizontal" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Java Second</p>
  
  <pre><code>public class second extends Activity {
      @Override
     protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_second);
      WebView w1=(WebView)findViewById(R.id.webView);
      w1.loadUrl("http://www.franklinpierce.edu/news.xml");
  }
  </code></pre>
  
  <p>Main Activity Java:</p>
  
  <pre><code>public class MainActivity extends Activity {
  EditText title,link,description;
  Button b1,b2;
  private String finalUrl="rss feed url";
  private HandleXML obj;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      link = (EditText) findViewById(R.id.editText);
  
      b2=(Button)findViewById(R.id.button2);
  
  
      b2.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent in=new Intent(MainActivity.this,second.class);
              startActivity(in);
          }
      });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  
  
      int id = item.getItemId();
  
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>RSSReader</p>
  
  <pre><code>public class RSSReader {
  private String link = "link";
  private String urlString = null;
  private XmlPullParserFactory xmlFactoryObject;
  public volatile boolean parsingComplete = true;
  
  public HandleXML(String url){
      this.urlString = url;
  }
  
  
  public String getLink(){
      return link;
  }
  
  
  public void parseXMLAndStoreIt(XmlPullParser myParser) {
      int event;
      String text=null;
  
      try {
          event = myParser.getEventType();
  
          while (event != XmlPullParser.END_DOCUMENT) {
              String name=myParser.getName();
  
              switch (event){
                  case XmlPullParser.START_TAG:
                      break;
  
                  case XmlPullParser.TEXT:
                      text = myParser.getText();
                      break;
  
                  case XmlPullParser.END_TAG:
  
                      if(name.equals("link")){
                          link = text;
                      }
  
  
                      else{
                      }
  
                      break;
              }
  
              event = myParser.next();
          }
  
          parsingComplete = false;
      }
  
      catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public void fetchXML(){
      Thread thread = new Thread(new Runnable(){
          @Override
          public void run() {
  
              try {
                  URL url = new URL(urlString);
                  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  
                  conn.setReadTimeout(10000 /* milliseconds */);
                  conn.setConnectTimeout(15000 /* milliseconds */);
                  conn.setRequestMethod("GET");
                  conn.setDoInput(true);
  
                  // Starts the query
                  conn.connect();
                  InputStream stream = conn.getInputStream();
  
                  xmlFactoryObject = XmlPullParserFactory.newInstance();
                  XmlPullParser myparser = xmlFactoryObject.newPullParser();
  
                  myparser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
                  myparser.setInput(stream, null);
  
                  parseXMLAndStoreIt(myparser);
                  stream.close();
              }
  
              catch (Exception e) {
              }
          }
      });
      thread.start();
  }
  </code></pre>