Android :: Unexpected End Of Document Exception
Nov 21, 2010
I'm getting a "SAXParseException: Unexpected end of document" error when trying to parse an xml document on android. The document in question is from the google weather api, but it seems to throw the same error regardless of the xml file in question (as long as the xml is valid) so I suspect it's a problem with my approach, rather than the xml. This is being done as a learning exercise, so I've probably (hopefully) overlooked something obvious. I've run the xml through an online validator, and it comes back as being well formed. (Can't tell me if it's valid as I don't have a DTD, but I dont think I need the DTD to parse the xml). This is the code that I'm using to try and parse the file:
private void refreshForecast() URL url;
try { url = new URL( "http://192.168.1.66:8000/google4.xml");
URLConnection connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection)connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// falls over here parsing the xml.Document dom = db.parse(in);
} } catch (ManyExceptions e) { ....
} A cutdown version of the xml that produces the error is:
<?xml version="1.0"?>
<xml_api_reply version="1">
<weather>
<forecast_information>
<city>Hamilton</city>
</forecast_information>
</weather>
</xml_api_reply>
The stacktrace is:
11-20 06:17:24.416: WARN/System.err(406): org.xml.sax.SAXParseException: Unexpected end of document
11-20 06:17:24.416: WARN/System.err(406): at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:131)
11-20 06:17:24.416: WARN/System.err(406): at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:110)
11-20 06:17:24.426: WARN/System.err(406): at com.dave.nzweather.WeatherApp.refreshForecast(WeatherApp.java:159)
11-20 06:17:24.426: WARN/System.err(406): at com.dave.nzweather.WeatherApp.onCreate(WeatherApp.java:100)
11-20 06:17:24.426: WARN/System.err(406): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-20 06:17:24.438: WARN/System.err(406): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-20 06:17:24.438: WARN/System.err(406): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-20 06:17:24.446: WARN/System.err(406): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-20 06:17:24.446: WARN/System.err(406): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-20 06:17:24.456: WARN/System.err(406): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 06:17:24.456: WARN/System.err(406): at android.os.Looper.loop(Looper.java:123)
11-20 06:17:24.456: WARN/System.err(406): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-20 06:17:24.466: WARN/System.err(406): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 06:17:24.466: WARN/System.err(406): at java.lang.reflect.Method.invoke(Method.java:521)
11-20 06:17:24.466: WARN/System.err(406): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-20 06:17:24.476: WARN/System.err(406): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-20 06:17:24.476: WARN/System.err(406): at dalvik.system.NativeStart.main(Native Method)
11-20 06:17:24.486: WARN/ROGER(406): org.xml.sax.SAXParseException: Unexpected end of document
In the interest of brevity, I've not included the original xml, but it's just the standard weather xml from googles feed. I've also tried a few completely different xml files, (including the sample from http://www.ibm.com/developerworks/xml/library/x-android/) and they all give the same error. (They also all validate as well formed when I run them through an online xml validator). This makes me think that it's not a problem with the xml, but rather with how I'm trying to feed it into the parser.
View 2 Replies
Jun 23, 2010
I have faced with issue about startActivityForResult() and onActivityResult(). If child activity started by the startActivityForResult() exit by unexpected exception the onActivityResult() is not called and I have no any ideas how can I handle this to get application working in a fail-safe manner ?
When my code runs child activity with startActivityForResult() it awaits until onActivityResult() will be invoked to get working further, but onActivityResult() is not calling and my code is "hang- up" (logically).
So the question is how can I handle all possible ways the child activity is finished (normally and by unexpected exception) to get fail-safe code ?
I have check the documentation for this issue but have found nothing relating issue.
View 4 Replies
View Related
May 10, 2009
I am attempting to integrate some previous libraries that we have within my new android project.
I have made several attempts including:
Importing the code as sub-projects (that are built using the android.jar)
Importing the code as jar files (from the built code)
Adding the files directly as part of my project
Reordering the dependencies
However for each one of these scenarios I keep getting the following exception thrown by the davlik compiler.
It is always picking the first class in the package (ie if I remove that class, it picks the next and so on).
It would appear to me that this is a compiler bug - somehow it's getting it's dependencies in a twist.
Anyone else experienced this? And/or have any ideas on how to get around this one?
UNEXPECTED TOP-LEVEL EXCEPTION:
CODE:................................
View 3 Replies
View Related
Jul 14, 2010
I created a sql lite database with the following columns:
static final String dbName="demoDB";
static final String tableName="Employees";
static final String colID="EmployeeID";
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE "+tableName+" ("+colID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
colName+" TEXT, "+colAge+" Integer);");
I want to select all the records in the database like this and display them in a gridview:SQLiteDatabase db=this.getWritableDatabase();Cursor cur= db.rawQuery("Select "+colName+", "+colAge+" from "+tableName, new String [] {});String [] from=new String []{DatabaseHelper.colName,DatabaseHelper.colAge};
int [] to=new int [] {R.id.colName,R.id.colAge};
SimpleCursorAdapter sca=new SimpleCursorAdapter(this,R.layout.gridrow,c,from,to);
GridView grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(sca);but i receive the following exception:java.lang.IllegalArgumentException: column '_id' does not exist.the db table does not have a column with name '_id'so what is wrong with this code
View 3 Replies
View Related
Feb 16, 2010
I have list of checkboxes in list binded by Custom simpleCurserAdapter. in my Custom simpleCurserAdapter ive override the newview and binview with my modifications. ive managed somehow to do multichoice.. wierd thing after i delete any item from my list , the first item's checkbox is being checked all of a sudden.. how does that happen? how can i solve it?
code: my curser SimpleCursorAdapter class:
CODE:......
I couldnt find another way of doing this, but this is how i set listeners to my checkboxses
CODE:.....
Now this is code part from the ListActivity class which desbribes the button which deleting the checked Box items
CODE:......................
View 3 Replies
View Related
Nov 30, 2009
I'm registering a sensor listener with this line of code.
mSensorManager.registerListener(this,mSensorManager.getDefaultSensor (Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);
The rate is set to SENSOR_DELAY_FASTEST with the expectation that I would receive events roughly every 20-30ms. It turns out that I receive events only every 200-220ms (just now, my event code simply logcats the system time).
No matter which rate I use, SENSOR_DELAY_NORMAL, SENSOR_DELAY_UI, SENSOR_DELAY_GAME, or SENSOR_DELAY_FASTEST, I get the same result?
View 15 Replies
View Related
Feb 12, 2010
Got a Samsung Moment a couple of weeks ago. Last night starting using Astrid (Task/ToDo app), which came pre-installed on my phone. When I launched Astrid for the first time, I got a warning message -- something about making sure Sprint Update or Sprint Updater doesn't kill Astrid, or ruin it, or something. Clearly, I didn't understand the message. But I clicked "Okay" anyway, and started using Astrid. But I'm worried that a Sprint Update could erase all my Astrid data -- my To Do's. I'm reluctant to create many Astrid tasks until I know how to prevent them from being unexpectedly erased. My questions: Can anyone explain the situation to me? (e.g., I have no idea who/when/how/where/what Sprint updates). Can anyone explain what I need to do to prevent the catastrophe about which Astrid was warning me?
View 1 Replies
View Related
Feb 9, 2010
I am pretty new to Android, the thing that bugs me the most about the IDE is that I am not able to get any information about an unexpected exception when it gets thrown, I can put a try catch block around identified code that generates it, but in many cases it takes time to find the line of code that generates the exception. is there any other way I can get the exception information? in JDT when an unexpected exception is thrown the call stack displays the exception class name. but in ADT this doesn't work.
View 13 Replies
View Related
Jun 19, 2010
The screen shot below is of a simplified version of the application from the Tab Layout tutorial. You can see a black horizontal line below the tabs. Why is it there and how can I remove it?
View 2 Replies
View Related
Mar 31, 2010
I have here a function that downloads data from a remote server to file. I am still not confident with my code. My question is, what if while reading the stream and saving the data to a file and suddenly I was disconnected in the internet, will these catch exceptions below can really catch that kind of incident? If not, can you suggest how to handle this kind of incident?
I call this function in a thread so that the UI won't be blocked.
CODE:...................
View 1 Replies
View Related
Apr 29, 2010
I'm currently working on a small update to a project and I'm having an issue with Relative_Layout and fill_parent in a list view. I'm trying to insert a divider between two sections in each row, much like the divider in the call log of the default dialer. I checked out the Android source code to see how they did it, but I encountered a problem when replicating their solution.
To start, here is my row item layout:
CODE:..........
The issue I'm facing is that each row has a thumbnail of varying height (ImageView01). If I set the RelativeLayout's layout_height property to fill_parent, the divider does not scale vertically to fill the row (it just remains a 1px dot). If I set layout_height to "?android:attr/listPreferredItemHeight", the divider fills the row, but the thumbnails shrink. I've done some debugging in the getView() method of the adapter, and it seems that the divider's height is not being set properly once the row has it's proper height.
Here is a portion of the getView() method:
CODE:.........
The rest of the method simply sets the appropriate text and images for the row.
Also, I create the inflater object in the adapter's constructor with: inflater = LayoutInflater.from(context);
Am I missing something essential? Or does fill_parent just not work with dynamic heights?
View 1 Replies
View Related
Nov 19, 2010
I've been implementing a logcat reader in java which uses the binary output of logcat (-B switch) rather than the text based formats. My code works for many of the entries, but frequently the binary log entries have an extra byte inserted which I can't account for, making the payload the wrong size.
From looking at various bits of the c++ code for both the logcat program itself and the logging apis, the binary format seems to be:
CODE:...........
Payload section of the header is (payloadlength bytes total):
CODE:...............
This file defines the struct: http://www.google.com/codesearch/p?hl=en#2wSbThBwwIw/include/cutils/l...
The extra byte I'm seeing occours after the nanosecond timestamp and before the log priority of the payload. e.g. Here is a hex dump of one of the log entries with the phantom byte:
The byte (in this instance) is 0x1D at offset 0x14 0000:
CODE:.......
The extra byte shifts the payload by 1, so the payload length becomes incorrect. I can't see where this byte is coming from.
I also tried the LogReceiver class in ddmlib, but that also fails to handle extra byte and produces garbage after it hits an entry with the extra byte: [url]
Here is a quick python script which demonstrates the problem. It reads and prints binary log entries in the expected format. It will raise an exception when it encounters an entry with an unexpected byte: [url]
The logcat program itself successfully reinterprets the binary format without jumping through any hoops, so I can only guess it's some kind of struct alignment artifact. Anyone encountered this or got any idea why the extra byte is appearing?
View 2 Replies
View Related
Mar 19, 2013
My memory card is always unexpectlly removed when my device is idle, so I have to wait my gallery recreate thumbnail if I want to use it
View 4 Replies
View Related
Nov 29, 2010
I updated my X10i to 2.1 on Orange and am noticing that there's a problem with my Timescape (great app btw) where the phone suddenly goes from Timescape spline to the Home Screen without me touching anything. The phone seems much slower now in loading some apps - one main example is the text/mms messaging app.
View 5 Replies
View Related
Dec 7, 2012
I got a surprise status notification today about completed automated backup. I see this message for he first time. Where it came from, as there was no activity attached to the notification.
I do my own backups and have the standard sync and backups disabled, and I have not installed anything particularly weird or non-market since the last time I reflashed the device. To the best of my knowledge nothing but my own backup does backups.
Which app may be responsible for it? I am quite uneasy having apps that backup who knows what who knows where.
Pic of the said notification attached: [URL] ......
The device is a rooted Nexus 7 with stock JB 4.2
View 1 Replies
View Related
Oct 20, 2010
I just bought Xperia10 mini yesterday and download the Pc companion and installed it ! when I connect my phone to that it says there is another better softwaredriver for phone when I try to update it starts and download the driver then almost at the end it gets error and says it couldnt be installed cuz of issues?
Then I installed Update service I get this :
http://img341.imageshack.us/img341/8500/sattan.jpg
The wireless is good and working after I try update service I get unxpected error and it resets my wireless
I have Windows 7 64BIT
View 3 Replies
View Related
Apr 9, 2010
If changing the orientation of my phone or the emulator I get the following output in LogCat:
04-09 11:55:26.290: INFO/WindowManager(52): Setting rotation to 1, animFlags=0
04-09 11:55:26.300: INFO/ActivityManager(52): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/1 nav=3/1 orien=2 layout=18}
04-09 11:55:26.460: INFO/UsageStats(52): Unexpected resume of client while already resumed in client
04-09 11:55:26.579: INFO/SearchPosition(807): Activity is paused
04-09 11:55:26.689: INFO/SearchPosition(807): Activity is resuming
SearchPosition is the activity that is displayed. Activity is paused is written in the onPause Method and Activity is resuming in the onResume method of the activity. I googled a little bit for the error message but I don't fully understand the meaning of it. I think it could mean that the old Activity is not properly destroyed after changing the screen orientation. Is this correct? If yes what causes the error? If this is not correct? What is the meaning of this output?
View 1 Replies
View Related
Oct 3, 2010
Several of my Android applications show the following type message in the logcat output:
I/UsageStats( 59): Unexpected resume of com.totsp.test while already resumed in com.totsp.test
In this case I created the default Hello World app by letting the ADT tool generate it, and it still gets this message. I am not doing anything special in onCreate and don't even have any other methods defined.
I realize this is an INFO level message, and it doesn't appear to hurt anything, but I was curious what was going on so I made a test application that keeps track of the onResume invocations. It is indeed re-resuming when this occurs. I'm wondering why this this occurs? While I haven't noticed a problem (other than these annoying log messages), it seems like it could be using more resources than necessary to do all this stuff an extra time.
I have searched and read a similar question here on SO, and the answer there seems dubious to me: http://stackoverflow.com/questions/2606470/unexpected-resume-of-package-name-while-already-resumed-in-package-name-erro. Specifically, no, you don't want to use android:configChanges="orientation" because that is just subverting the orientation tear down/resume, rather than fixing it. Even the documentation notes "this attribute should be avoided and used only as a last-resort" (http://developer.android.com/intl/de/guide/topics/manifest/activity-element.html#config).
Also I have seen thread in the Android dev group where Mr. Murphy says the "unexpected resume" is "benign": http://groups.google.com/group/android-developers/browse_thread/thread/567410dbfcc163c2.
I'll dig into the source when I get a chance, but I figured I would first just ask the all-knowing hivemind and see if someone already knows: why does this occur, and is it truly benign?
View 1 Replies
View Related
Dec 18, 2009
Can anyone point me to a explanation for or explain to me how I can easily parse the XML and get values of a w3c.Document on Android using only Android OS Libs?I tried to use a implementation of dom4j, but it is very slow
View 2 Replies
View Related
Apr 4, 2010
The documentation shows that you can directly link to your app on Android Market place. But every HTTP url I attempted, I am getting a page not found error. I am wondering if there is something wrong with the documentation or is there a rules change where we can directly link to apps we created. if that is the case, why is this documentation still exist pointing to incorrect information?
View 2 Replies
View Related
Aug 16, 2010
I have Jot Not for iPhone which does a great job of scanning documents, white boards, etc. and putting them into a multiple page PDF.
View 8 Replies
View Related
Jan 28, 2010
I am trying to parse an HTML document that is missing an end tag on one of the elements (input tag). Anyone know how to get the parser to ignore that it doesn't have an end tag and just read an attribute value?
DocumentBuilderFactory dbf DocumentBuilderFactory.new Instance(); Document Builder builder = dbf.newDocumentBuilder(); Document dom = builder.parse(url.openStream()); //ERROR HERE Error: 01-28 21:34:38.384: WARN/System.err(12108):org.xml.sax.SAXParseException: expected: /input read: div (position:END_TAG </div>@21:10 in java.io.InputStreamReader@432749f8)
View 11 Replies
View Related
Mar 18, 2010
Is there any document visualization toolkit available for android?
View 2 Replies
View Related
Dec 7, 2009
Is there any way to display raw XML in an Android Browser. My XML file is being stripped of all the XML tags, and I need them for my map application to work correctly.
View 2 Replies
View Related
Mar 22, 2010
I am writing and publishing my apps on android and would like to provide help document (manual) to users of my apps. I've seen apps open up external web pages as their help, or use html view to open local html documents. Are these the ways we are supposed to deliver manual to our users?
View 2 Replies
View Related
Sep 15, 2010
I am working on an Android Application where I need to open an MS_Word foramt file.How can this be possible in android? The context is the file should be viewed in the same way as if we view msword document in desktop.
View 1 Replies
View Related
Sep 26, 2010
This should be trivial, but for whatever reason I can't find any easy way to do this. Coming from C# where this is a 1 line call, I don't understand why Java makes this so complicated, and on top of that android leaves even that out of its libraries. Anyway all I want to do is write an
org.w3c.dom.Document
that I have populated to a xml file. It should be as easy as opening a stream and writing document.toString(). But that doesn't work. My hope is I'm just missing something.
View 3 Replies
View Related
Sep 9, 2009
I'm using org.w3c.dom.Document to create a document and I need now to write it into a .XML file. I saw tutorials referring the Java.XML.transform.Transformer package but this one is not available in the Android platform.
View 5 Replies
View Related
Jul 30, 2010
I am trying to retrieve a XML document from web service. I am passing a soap object with a token implementing the OAuth concept and retrieving the data. But the data does not turn out to be in XML format. It contains a curly braces in the place of start tag and semicolons when it ends. Is there any way to retrieve the document in XML format as such?
View 17 Replies
View Related
Jun 15, 2010
I did a quick search and couldn't find anything similar to this thread. I am taking a four day train trip across the country (The US) in August and I was wondering what apps would be best to document this? My ideal goal would be to have my route tracked, perhaps Google Maps Integration somehow, and also have pictures/text messages from along the way put onto the map wherever they were taken/written. I would like this to be viewable by friends/family online as the trip is happening.If I can't get the route tracked, that's fine, but I would like someway to display the pictures/texts from along the trip.What App or combination of apps would you guys recommend I use to accomplish this?I am familiar with WordPress and have used the Android Wordpress App a bit, but not too in depth. Would I be able to use this? Or is there a better way?Oh, and one more thing, unrelated. I noticed some apps (Google Voice for example) listed "Services that cost you money" as one thing they have access too. What exactly does this mean?
View 12 Replies
View Related