Android :: Using Android SAXParser - One My XML Elements Is Breaking In Half

Mar 30, 2010

Im using the SAXParser object do parse the actual XML.

This is normally done by passing a URL to the XMLReader.Parse method. Because my XML is coming from a POST request to a webservice, I am saving that result as a String and then employing StringReader / InputSource to feed this string back to the XMLReader.Parse method.

However, something strange is happening at the 2001st character of the XMLstring. The 'characters' method of the document handler is being called TWICE in between the startElement and endElement methods, effectively breaking my string (in this case a project title) into two pieces. Because I am instantiating objects in my characters method, I am getting two objects instead of one.

This line, about 2000 chars into the string fires 'characters' two times, breaking between "Lower" and "Level"

<title>SUMC-BOOKSTORE, LOWER LEVEL RENOVATIONS</title>

When I bypass the StringReader / InputSource workaround and feed a flat XML file to XMLReader.Parse, it works absolutely fine.

Something about StringReader and or InputSource is somehow screwing this up.

Here is my method that takes and XML string and parses is through the SAXParser.

CODE:.............

How to not have 'characters' firing off twice when I get to this point in the XML String.

Or, show me how to use a POST request and still pass off the URL to the Parse function.

Android :: Using Android SAXParser - one my XML Elements is breaking in half


Android :: Creating A Drawable Rectangle In Xml With One Gradient On Top Half And Another On The Bottom Half

Feb 21, 2010

I'm trying to create a drawable in xml, a rectangle with one gradient on the top half, and another on the bottom half.

This is NOT the way to do it, apparently:

CODE:................

How can I do this, preferably in a way that makes it stretchable to any height?

View 2 Replies View Related

Sprint HTC Hero :: Second Half Of Battery Drains Faster Than First Half - No Music Playing - No Wi-fi - No Internet Browsing

Oct 15, 2009

I used my Hero this morning/afternoon with music, wi-fi, internet browsing, and I used up the first half of the battery. And after that, I have been mostly studying and not using my phone... but the second half of the batter drains, it seems like, FASTER than the first half did! No music playing, no wi-fi, no internet browsing? Is this normal? Is it just the nature of these batteries?

View 2 Replies View Related

Android :: SAXParser With POST To URL

Jan 22, 2009

I have an API. I'm using that requires me to POST instead of use GET to submit my credentials before receiving back my XML response. I've parsed a bunch of various XML services like this, but this is the first time I've run across having to post to the URL. Basically they want a username and password parameter submitted as a post to the URL before the XML is fed back. Does anyone have a working example, or maybe able to point me in the right direction?

View 3 Replies View Related

Android :: How To Pause SAXParser?

Aug 27, 2010

I'm using SAXParser to parse large xml document from the net. And sometimes I need to pause SAXParser. I know how to stop parser by using SAXException, but how I can paused it? May be can I stop parser and then set up it to pass already parsed tags?

View 2 Replies View Related

Android :: SAXParser And Malformed XML

Aug 14, 2010

I am using a saxparser to read RSS XML from the web and populate listviews. Everything works fine until I come across malformed XML, usually encoding related, and my reader falls over. I have changed it so that it gets as many items parsed and populated before falling over (by default if it finds a malformed XML, then it will give up and return an empty collection). The problem is, the next time I try and view that feed (or any other feed), it still has the contents after the malformed bit hanging around.

For example, the first time it now shows all the items upto the malformed item, if I refresh, it will only show items after, refresh again, it will show items upto and so forth. The weird thing is, I create a new instances of everything every time. So I don't understand why stuff is handing around. It's like there is some read pointer, or connection that needs to be closed and reset, but I can't for the life of me work out what or where!

My GetFeed method:
private RSSFeed getFeed(String urlToRssFeed) {
SAXParserFactory factory;
SAXParser parser; XMLReader xmlreader;
URL url; InputSource is;
try { url = new URL(urlToRssFeed);
factory = SAXParserFactory.newInstance();
factory.setValidating(false);
parser = factory.newSAXParser();
xmlreader = parser.getXMLReader();
xmlreader.setContentHandler(m_FeedHandler);
is = new InputSource(url.openStream());
xmlreader.parse(is); m_ErrorCode = NOERROR;
} catch (SAXParseException e) { e.printStackTrace();
m_ErrorCode = XMLFORMAT;
} catch (Exception e) { e.printStackTrace();
m_ErrorCode = CONNECTION;
} finally { is = null;
url = null; parser = null; factory = null;
return m_FeedHandler.getFeed();
//May be complete, partial or empty.
} }

View 2 Replies View Related

Android :: SAXParser Fails On Some RSS Feeds

Feb 28, 2009

I'm using the SAX parser to read some RSS feeds and have found a problem. Some feeds, for example CNN Money Top Stories, have embedded some characters in their content, i.e. the copyright symbol. Well, that's not valid XML and the SAX Parser fails with an exception "invalid token". The only help I have seen given is to fix the XML at the source and that's not an option obviously. So, I can think of 2 options and they both stink:

(a) read the content first, scrub it, and then pass it to the parser.
(b) Use DOM instead of SAX.

What I *want* to do is make the parser a little more forgiving and just accept or discard/ignore the bad text. I'm not have any luck with setErrorHandler. My error handler does not get called.

View 7 Replies View Related

Android :: Youtube API - SAXParser Error

Jul 22, 2010

I have been trying to use the youtube APIs on the Android Platform (version 1.6) and have been stuck with the SAXParser whenever I send out a query from the following line of code:
VideoFeed videoFeed = service.query(query, VideoFeed.class);

I initially had errors with the SAXParser for which I applied the patch suggested here:
https://code.google.com/p/android/issues/detail?id=9493

After this, the previous error that I had which called an ExternalParametersEntities exception was resolved but I now get a Verify Error:
com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory $SecureSAXParserFactory

Would anyone know how to get around this error? Is there any other way to use the youtube API query on an Android platform?

View 3 Replies View Related

Android :: SAXParser Getting Stuck On Certain Characters

Jan 26, 2009

I'm using a SAXParser to parse an XML document and its getting stuck on certain symbols like the 'trademark' symbol and I think even double- quotes". I really don't need these characters so it would be fine if the parser just skips over these. Instead it throws an exception and quits parsing the document. What can I do?

View 7 Replies View Related

Android :: Using SAXParser To Get List Of Strings To Arraylist

Jun 21, 2010

I'm trying to parse a web service response using SAXParser and get certain values, store them into an arraylist, then display them in a listview. Example XML being returned from web service:
<ArrayOfStrings>
<string>value</string>
<string>value</string>
<string>value</string>
</ArrayOfStrings>

Here is my SAXHandler class:
public class SAXHandler extends DefaultHandler {
private boolean outertag = false;
private boolean mytag = false;
ArrayList<String> alist;
public ArrayList<String> getList(){
return this.alist;
} @Override
public void startDocument() throws SAXException {
} @Override
public void endDocument() throws SAXException{
} //@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
if (localName.equals("ArrayOfString")){ this.outertag=true;
}else if (localName.equals("string")){ this.mytag=true;
} }
@Override
public void characters(char ch[], int start, int length) {
if (this.mytag){ String s = new String(ch, start, length);
alist.add(s);
} }
@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
if (localName.equals("ArrayOfString")){ this.outertag=false;
}else if (localName.equals("string")){ this.mytag=false;
} } }

And here's my method calling and returing my web service:
try{ URL url = new URL("xxxxxxx");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
SAXHandler SAXHandler = new SAXHandler();
xr.setContentHandler(SAXHandler);
xr.parse(new InputSource(url.openStream()));
ArrayList<String> stateList = SAXHandler.getList();
aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, stateList);
RESTlist.setAdapter(aa);
I keep getting an exception and I don't know why. Can anyone give me a hand?

Logcat:
06-21 20:10:47.901: ERROR/AndroidRuntime(472): Uncaught handler: thread main exiting due to uncaught exception
06-21 20:10:47.950: ERROR/AndroidRuntime(472): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pa.passammain/com.pa.passammain.RESTtest}: java.lang.NullPointerException: println needs a message
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.os.Looper.loop(Looper.java:123)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invoke(Method.java:521)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at dalvik.system.NativeStart.main(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): Caused by: java.lang.NullPointerException: println needs a message
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.util.Log.println(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.util.Log.e(Log.java:208)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.pa.passammain.RESTtest.onCreate(RESTtest.java:82)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): ... 11 more

After editing how my error is displayed in my try/catch i'm not longer getting an exception, but just a blank screen. Here is what my logcat is displaying:

06-21 20:22:00.330: WARN/System.err(542): java.lang.NullPointerException
06-21 20:22:00.352: WARN/System.err(542): at com.pa.passammain.SAXHandler.characters(SAXHandler.java:45)
06-21 20:22:00.352: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.text(ExpatParser.java:166)
06-21 20:22:00.362: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.append(Native Method)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:506)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
06-21 20:22:00.381: WARN/System.err(542): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
06-21 20:22:00.381: WARN/System.err(542): at com.pa.passammain.RESTtest.onCreate(RESTtest.java:71)
06-21 20:22:00.391: WARN/System.err(542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-21 20:22:00.391: WARN/System.err(542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-21 20:22:00.401: WARN/System.err(542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
06-21 20:22:00.401: WARN/System.err(542): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-21 20:22:00.410: WARN/System.err(542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-21 20:22:00.410: WARN/System.err(542): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 20:22:00.420: WARN/System.err(542): at android.os.Looper.loop(Looper.java:123)
06-21 20:22:00.420: WARN/System.err(542): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-21 20:22:00.420: WARN/System.err(542): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 20:22:00.430: WARN/System.err(542): at java.lang.reflect.Method.invoke(Method.java:521)
06-21 20:22:00.430: WARN/System.err(542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-21 20:22:00.442: WARN/System.err(542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-21 20:22:00.442: WARN/System.err(542): at dalvik.system.NativeStart.main(Native Method)

View 1 Replies View Related

Android :: SAXParser Invalid Token Exception And Attribute Value

Jan 1, 2010

I am using SAXParser to parse an html page (any better solution?) and have this exception:
W/System.err( 1358): org.apache.harmony.xml.ExpatParser $ParseException: At line 1, column 59: not well-formed (invalid token)
I have reduced the page to this:
<div id="submenu"><a href="/compte/console.pl? id=382730&idt=1cf6b94aa1a4cf84"></a></div>
And what causes the exception is the '&' inside the href attribute value.

Here is a minimalist test code:
DefaultHandler emptySaxHandler = new DefaultHandler() {};
String xmlstr = "<div id="submenu"><a href="/compte/console.pl?id=382730&idt=1cf6b94aa1a4cf84"></a></div>";
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(new ByteArrayInputStream(xmlstr.getBytes ()),emptySaxHandler);

Is this a normal behaviour or kind of bug? If normal, what should do to preprocess the string before parsing?

View 3 Replies View Related

Android :: How To Prevent Our Application From Jail Breaking?

Feb 18, 2010

i have a android application which is ready to release .so to release i have put the app in android market .the user can buy the app and can install the app into the phone.android market wont provide any apk file to the user .so normally we need not bother about re distribution of of the app to the unauthorized persons(who didn't buy the app). But what my problem is ,I heard that there is a jail breaking concept which can allow the hacker to get the apk file(installation file) from the device .(even though android market not giving the apk file to the user ).then he can distribute the apk file to all(to unauthorized persons ).how to avoid it.is there any thing to restrict the unauthorized person in using our app,even though he get the apk file . does android market provides the details of the users who has buy the app by paying?

View 14 Replies View Related

HTC Droid Eris :: Volume Only Go Up Half Way - Even Alarm Volume Only Goes Half Way

Feb 23, 2010

why is it when i hit the volume rocker on the side, it only goes half way? i mean, its still loud as hell, but still. Even the Alarm volume only goes half way.

View 3 Replies View Related

Android : Prevent Long URL From Breaking In Generated Email?

Mar 28, 2010

I am generating an email in my app in which I include a long URL. The entire URL appears in the email but the clickable link portion of it consists of only the first 90 characters. Why does this happen and how can I prevent it?

View 2 Replies View Related

Android :: Implementing Characters Method Using SAXParser On Android?

Feb 8, 2010

I am parsing xml using the SAXParser and want to know if this is the right way to implement the characters method. Assume there's a class-level String variable named elementValue and it is initialized to "" in the startElement method.

Here is the characters method:
@Override
public void characters(char[] ch, int start, int length) {
String charsToAppend = new String(ch, start, length);
elementValue = elementValue + charsToAppend;
}
Is it correct that we need to append to the value we have so far and is the append being done correctly? Also, why does the characters method give the start index? Won't it be zero every time?

View 2 Replies View Related

Android :: Can Prevent Words From Breaking In Textview When Using Wrap Content In Android

Sep 20, 2010

I am in the process of trying to convert a desktop app to Android - and am struggling with some very basic stuff. When I specify a layout including a textview that holds a sizable amount of text wrap_content seems to arbitrarily break in the middle of a word - and I can not find any documentation indicating this can be controlled.

View 1 Replies View Related

Android :: Failing Android JUnit Tests, Not Breaking My Ant Script Like I Expect

Jun 2, 2010

Failing JUnit tests, not breaking my Ant script like I expect?

My continuous integration server runs an Ant script, which calls something like:
/tests/ant run-tests

My JUnit tests run, but with errors:

CODE:..............

The errors are OK, but my build script keeps going (eventually publishing my broken app to my testers - bad!). What I would expect is for the instrimentaiton to throw a build error, so my continuous integration server (TeamCity in this case) realises that something has gone wrong and reports a broken build. The "failonerror" is already set in the relevant macrodef, so I'm not sure what else I can do?

View 1 Replies View Related

Android :: Line-breaking Widget Layout For Android

Feb 14, 2009

I'm trying to create an activity that presents some data to the user. The data is such that it can be divided into 'words', each being a widget, and sequence of 'words' would form the data ('sentence'?), the ViewGroup widget containing the words. As space required for all 'words' in a 'sentence' would exceed the available horizontal space on the display, I would like to wrap these 'sentences' as you would a normal piece of text.

The following code:

code:...................

yields something like the left picture, but I would want a layout presenting the same widgets like in the right one.

Is there such a layout or combination of layouts and parameters, or do I have to implement my own ViewGroup for this?

View 4 Replies View Related

Android :: Cannot Read Two Different Tags Using SAXParser In Android?

Sep 23, 2010

I am using SAXParser to parse an XML document having three different tags. But in the result I get the value of only "one tag and not Other two tags. Can someone explain?
My XML is :
<outertag>
<innertag>hello</innertag>
<othertag>good morning</othertag>
<thirdtag Attribute="its a pleasant day"/>
</outertag>

View 1 Replies View Related

HTC Desire :: Phone Keeps Breaking Up?

Jul 9, 2010

My signal bar seems ok yet i cant have conversations on my phone cuz it just keeps breaking up?

View 1 Replies View Related

Samsung Moment :: Speakerphone - Quite Muffled And/or Breaking Up

Aug 22, 2010

When using the built in speaker phone on my Samsung Moment, the person on the other end of the call complains that I am quite, muffled, and/or breaking up; I can hear them fine, and it doesn't matter how close or far the mic is from my mouth.

View 3 Replies View Related

Motorola Droid :: Person On Other End Saying They Are Breaking Up / When Using Bluetooth In Car?

Jan 5, 2010

Has anyone else noticed the person on the other end saying they are breaking up when using bluetooth in a car? My wife says all the time when I call her from the car I sound like I am breaking up and she has a hard time hearing me. Never had any issue with the old EnV, is this common for the Droid?

View 1 Replies View Related

Motorola Droid :: Chevy's Kernal Breaking Titanium

Mar 8, 2010

It looks like Chevy's kernal is breaking the root access for Titanium. Anyone else having the same issue? When I first installed BB .7, Titanium worked fine. Then I installed Chevy's kernal and now it doesn't have root access. Looks like a couple other people are having the same issue on AllDroid. I'm using BB .7 with Chevy's 1ghz kernal.

View 10 Replies View Related

General :: What Apps Can Be Moved To SD Card Without Breaking Any Functionality

Jul 27, 2013

what apps can be moved to the sd card without breaking any functionality.

What google apps are safe to move?

Is is ok to move Cloud storage apps like Dropbox?

Is it okay to move stuff like calculator, calendar etc?

Is it okay to move messaging apps like whatsapp?

View 1 Replies View Related

Android :: Breaking Upgrades In Android

Jul 30, 2010

It will save a lot of coding if I am able to make a breaking change to my Android application. Instead, they will have to download a clean install and visit a URL to reinitialise the application data.

According to the documentation, "if the package name and signing certificate do not match those of the existing version, Market will consider it a new application and will not offer it to users as an update." This would allow me to publish a new version of the application without the user being able to accidentally upgrade and break the application.

If I do upload a new version of my application with a different signing certificate, will the application appear in the application store twice? If so, is there any way to prevent users from downloading the old application?

View 1 Replies View Related

Android :: Two XML Elements With Same Id

Nov 10, 2010

I'm trying to modify two TextViews in exactly the same way. I thought I can give them same id and with findViewById() and setText() methods change those TextViews in two lines. But it seems only one TextView is changed.Is there a way to do this?Or I have to make different ids for every element, get every element by findViewById() method and set it's text?

View 3 Replies View Related

Android :: Half - Downloaded App - Says Installed

Nov 15, 2010

So a few days ago I went to download a few apps. None of them seemed to want to download and I was pretty annoyed about this for about 2 days. Suddenly the Market seemed to work again, and I got 5 or 6 notifications of successfully installed apps. Winner

Unfortunately, there's one that seems not to have downloaded: "Street View On Google Maps". It thinks it's downloaded, but it's not there. If I go to delete apps on my phone, I can't see it. If I go to place an app or a widget on my home page, I can't see it. However, if I find it in the market, it says it's installed. And if I tap it in the market, both the "Open" and "Uninstall" buttons are greyed out. Does anyone have any idea what's going on here and how I can fix it? If it makes any difference, I'm on a HTC Desire HD.

View 17 Replies View Related

Android :: Seekbar Half Clickable

Mar 2, 2010

I have seekbar wich is for example 100dp height. How can i make only the top 50dp to be clickable and the down 50dp just to be covered with the progress.

View 2 Replies View Related

Android :: OpenGL Half Screen

Oct 7, 2010

I have follow an example of an opengl application and I don't know why is this thing happening...I have a GLSurfaceView with it's corresponding renderer drawing a triangle. But, instead of getting the whole view on screen, I have just the upper half, and it's also duplicated as you can see on the picure. I'm using a Nexus One.

View 3 Replies View Related

Android :: Inner Elements During The Xml Parsing

Aug 23, 2010

I could not get any inner elements during the xml parsing. looks like parser see only outer tag A. Could you show me error?

CODE:.......................

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved