I am following a course online by Grant Klimaytys on skillshare with Android Studio and its going over how to setup a simple RSS feed app from scratch. Well I've gotten to the point where he integrates the Simple Rss2 Android jar from Salendron on github. I've followed his instructions to the letter from the adding the jar as a library for my app as well as copying and pasting the sample code into the correct place within my main activity.java file but when I go to run a debug I am not seeing the log.d output that he is on the tutorial. I have searched far and wide and there aren't any other people talking about having this same issue. I am trying to stick to the tutorial as closely as possible but I am worried that since it is 2 years old there just may be some incompatibilities that I am unaware of.
Anyway here is the code from my MainActivity.java
package com.katsthings.personalrssfeed;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import java.util.List;
import at.theengine.android.simple_rss2_android.RSSItem;
import at.theengine.android.simple_rss2_android.SimpleRss2Parser;
import at.theengine.android.simple_rss2_android.SimpleRss2ParserCallback;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(fab.getContext(), AddFeedActivity.class);
startActivity(intent);
}
});
SimpleRss2Parser parser = new SimpleRss2Parser("http://pingeb.org/feed",
new SimpleRss2ParserCallback() {
@Override
public void onFeedParsed(List<RSSItem> items) {
for(int i = 0; i < items.size(); i++){
Log.d("SimpleRss2ParserDemo",items.get(i).getTitle());
}
}
@Override
public void onError(Exception ex) {
// Toast.makeText(mContext, ex.getMessage(), Toast.LENGTH_SHORT).show();
}
});
parser.parseAsync();
}
In the logcat I should be seeing D/SimpleRss2ParseDemo but unfortunately I am not.
It's likely you're throwing an exception, but because you commented out Toast in the onError() method, you never see anything.
I found out the library doesn't handle HTTP->HTTPS redirects very well. When I used the provided example RSS feed located at http://pingeb.org/feed in the demo program, it threw a RuntimeException because of an empty input stream.
When I tossed the URL into a browser, I saw it redirected to the HTTPS version of the website. I changed the URL in the code to https://pingeb.org/feed" and everything worked well.