Omnimaga
General Discussion => Technology and Development => Computer Programming => Topic started by: Eeems on November 07, 2011, 08:50:00 pm
-
Error Log: http://pastebin.com/YaP28L19
Code in question: http://pastebin.com/sDYgwB5B (line 56, called from line 43)
Full source code: http://dl.dropbox.com/u/763272/android/Omnimaga.zip
I'm thinking it's the fact that (Node)list.item(i) is returning a null. No idea if that is the problem though. Anybody have a fix/better way to do this?
( I've tried using SAX to parse the xml, but it keeps on not working ( returning a blank feed ) ).
-
Actually, list.item(i) is not returning null, but list.item(i).getNodeValue() is. According to the table at the top of this (http://developer.android.com/reference/org/w3c/dom/Node.html) page, the nodeValue of an instance of Element is always null. Anyway, I will try to see if I can get SAX to work.
-
SAX as in Cemetech's shoutbox? I'M confused here ???
-
SAX as in Simple API for XML. :)
-
Oh ok, I got confused there. I was wondering if Eeems was writing something for Cemetech that allows people to use SAX from a mobile device or something (like the TI-Planet app on iDevices). SAX is the acronym of their shoutbox, hence the confusion ;D
-
Cool, it works. I created an RSS parser that uses SAX, then I uncommented your code and made a few minor changes, and it works!
Anyway, I'll edit when I get it uploaded.
Edit: http://jacob.heliohost.org/Omnimaga.zip (http://jacob.heliohost.org/Omnimaga.zip)
-
Thanks! Ill test it out when I get home from work.
EDIT: Alright just about to test now. You just had to change my source file setup didn't you ;P
EDIT2: Alright it works, although clicking on an item doesn't give more info, it crashes. Thanks a ton though!
-
Feel free to change the packages back. I rewrote the RSS Parser like 4 times, and each time I moved it to a new package instead of deleting the old code. :P
Also, the more info page works fine for me. What version of Android are you testing it on?
-
2.3.7 ( CyanogenMod 7 )
It's giving me an error on startActivityForResult(itemintent,0);
Logcat of the error:
11-08 08:25:42.359: E/AndroidRuntime(18774): FATAL EXCEPTION: main
11-08 08:25:42.359: E/AndroidRuntime(18774): android.content.ActivityNotFoundException: Unable to find explicit activity class {org.omnimaga.eeems/org.omnimaga.eeems.ShowDescription}; have you declared this activity in your AndroidManifest.xml?
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.app.Activity.startActivityForResult(Activity.java:2827)
11-08 08:25:42.359: E/AndroidRuntime(18774): at org.omnimaga.eeems.OmnimagaActivity.onItemClick(OmnimagaActivity.java:61)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.widget.ListView.performItemClick(ListView.java:3513)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1849)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.os.Handler.handleCallback(Handler.java:587)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.os.Handler.dispatchMessage(Handler.java:92)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.os.Looper.loop(Looper.java:130)
11-08 08:25:42.359: E/AndroidRuntime(18774): at android.app.ActivityThread.main(ActivityThread.java:3835)
11-08 08:25:42.359: E/AndroidRuntime(18774): at java.lang.reflect.Method.invokeNative(Native Method)
11-08 08:25:42.359: E/AndroidRuntime(18774): at java.lang.reflect.Method.invoke(Method.java:507)
11-08 08:25:42.359: E/AndroidRuntime(18774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-08 08:25:42.359: E/AndroidRuntime(18774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-08 08:25:42.359: E/AndroidRuntime(18774): at dalvik.system.NativeStart.main(Native Method)
-
It appears, according to the error, that you need to declare that class as an activity in your AndroidManifest.xml file. Also, does the ShowDescription class extend Activity?
-
It appears, according to the error, that you need to declare that class as an activity in your AndroidManifest.xml file. Also, does the ShowDescription class extend Activity?
Oh lol, I just copied over the source files, didn't think about AndroidManifest.xml
ShowDescrition should extend it I think, check out the zip.
-
Alright, I got it to work now, I do have an issue though, but it has nothing to do with the code really.
The first time you try to access Omnimaga from anywhere it take a really long time to access, apparently longer then SAXParser's timeout is so it's impossible to connect to the Omnimaga RSS. I can't seem to figure out a way to extend the timeout of SAXParser so if anybody knows how that would be helpful. I've also contacted Netham45 about figuring out why this is happening.
( Yes I know this is a doublepost :P )
-
SAXParser in a very round-about way eventually uses a URLConnection, so you might as well create your own and set its timeout.
public RSS(String uri) {
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
URL url = new URL(uri);
URLConnection conn = url.openConnection();
conn.setConnectTimeout(0);
conn.setReadTimeout(0);
parser.parse(conn.getInputStream(), new RSSHandler());
} catch (SAXException ex) {
ex.printStackTrace();
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
}
}
-
SAXParser in a very round-about way eventually uses a URLConnection, so you might as well create your own and set its timeout.
public RSS(String uri) {
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
URL url = new URL(uri);
URLConnection conn = url.openConnection();
conn.setConnectTimeout(0);
conn.setReadTimeout(0);
parser.parse(conn.getInputStream(), new RSSHandler());
} catch (SAXException ex) {
ex.printStackTrace();
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
}
}
Alright thanks, I'll try that when I get home tomorrow morning from work ( leaving now )