Help | RSS Reader Feeds | Socket Exception

by Gaurav » Tue, 28 Apr 2009 22:20:50 GMT


Sponsored Links
 i,

I am trying to access rss feeds :

RSSFEEDOFCHOICE = "http://rss.news.yahoo.com/rss/entertainment";

Below is the code:

try
{
// setup the url
URL url = new URL(urlToRssFeed);

// create the factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// create a parser
SAXParser parser = factory.newSAXParser();

// create the reader (scanner)
XMLReader xmlreader = parser.getXMLReader();
// instantiate our handler
RSSHandler theRssHandler = new RSSHandler();
// assign our handler
xmlreader.setContentHandler(theRssHandler);
Log.i("getFeed", "before inputsource ");
// get our data via the url class

//InputSource is = new InputSource(inputStream);
InputSource is = new InputSource();
is.setByteStream(url.openConnection().getInputStream());
// perform the synchronous parse
xmlreader.parse(is);
// get the results - should be a fully populated RSSFeed
instance, or null on error
return theRssHandler.getFeed();
}
catch (Exception ee)
{
Log.e("getFeed", "ee ==> " +ee.getMessage(),ee);

// if we have a problem, simply return null
return null;
}


below is the exception trace:

04-28 19:47:54.155: INFO/RSSReader: onCreate(854): START
04-28 19:47:54.226: INFO/RSSReader: onCreate(854): RSSFEEDOFCHOICE
http://rss.news.yahoo.com/rss/entertainment
04-28 19:47:54.235: INFO/getFeed(854): urlToRssFeed ==>
http://rss.news.yahoo.com/rss/entertainment
04-28 19:47:54.306: INFO/getFeed(854): before inputsource
04-28 19:47:54.355: ERROR/OSNetworkSystem(854): unknown socket error
-1
04-28 19:47:54.389: ERROR/getFeed(854): ee ==> unknown error
04-28 19:47:54.389: ERROR/getFeed(854): java.net.SocketException:
unknown error
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl
(Native Method)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.platform.OSNetworkSystem.createSocket
(OSNetworkSystem.java:79)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.net.PlainSocketImpl2.create
(PlainSocketImpl2.java:59)
04-28 19:47:54.389: ERROR/getFeed(854): at
java.net.Socket.checkClosedAndCreate(Socket.java:763)
04-28 19:47:54.389: ERROR/getFeed(854): at java.net.Socket.connect
(Socket.java:910)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>
(HttpConnection.java:61)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager
$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection
(HttpConnectionManager.java:67)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection
(HttpURLConnection.java:800)
04-28 19:47:54.389: ERROR/getFeed(854): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect



Other Threads

1. how to change TextSwitcher's textcolor or textsize??

dear all
i have a trouble in TextSwitcher , there are simple code from the api
demo

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.text_switcher_1);

        mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
        mSwitcher.setFactory(this);

        Animation in = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in);
        Animation out = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out);
        mSwitcher.setInAnimation(in);
        mSwitcher.setOutAnimation(out);

        Button nextButton = (Button) findViewById(R.id.next);
        nextButton.setOnClickListener(this);

        updateCounter();
    }

    public void onClick(View v) {
        mCounter++;
        updateCounter();
    }

    private void updateCounter() {
        mSwitcher.setText(String.valueOf(mCounter));
    }

    public View makeView() {
        TextView t = new TextView(this);
        t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
        t.setTextSize(36);

        return t;
    }

i want change the textcolor or textsize whe i click the button,  how
can i do? thx a lot .

-- 

2. PC Suite For LG GW620 aka for All Android Phone :

Menjawab pertanyaan Om Jimmy di thread :

3. iPhoDroid: Install Android on iPhone 2G and iPhone 3G the Easy Way !

4. Encrypt and decrypt .apk files

5. upgrade ROM aPad/iRobot 2nd generatio

6. Use DownloadProvider or not?

7. Intro plus question :)