AssertionError on android.util.Xml.parse

by Cleverson » Fri, 23 Apr 2010 06:09:40 GMT

Sponsored Links

I'm getting an AssertionError when calling Xml.parse. This error
usually occurs when I run the app and keep switching the phone
connectivity from Wifi to 3G and vice versa. I checked the source code
of the android.util.Xml class and see something that I couldn't not
understand well, for example

    public static void parse(InputStream in, Encoding encoding,
            ContentHandler contentHandler) throws IOException,
SAXException {
        try {
            XMLReader reader = new ExpatReader();
            InputSource source = new InputSource(in);
        } catch (IOException e) {
            throw new AssertionError(e);

Is it "normal" to handle an IOException like it is done in this class?
I mean, why catching a checked exception and turn it to an
AssertionError? Should clients be supposed to catch AssertionErrors
when calling the parse method?

Thanks in advance!


Other Threads

1. Is there a way to make the MediaPlayer non-blocking

I figured out how to play sounds.

MediaPlayer mMediaPlayer = MediaPlayer.create(this, R.raw.mysound);

However, the .start() call blocks the application until it is done
playing.  Is there a way around this?



2. Question about defining selector drawable


I am trying to setup a selector drawable in my asset file like this:
* 2 different images for 'on'/'off' mode in rest mode (i.e. it does
not has focus)
* another 2 different images for 'on'/'off' mode in focus mode (i.e.
it has the focus).

In my case, the rest mode works, but the 'focus' mode does not.

Can you please tell me what am I missing in the focus mode? Thank you.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="">

<!-- these 2 images works --->
    <item android:state_checked="false" android:drawable="@drawable/off" />
    <item android:state_checked="true" android:drawable="@drawable/on" />

  <!-- these 2 images does not work -->
    <item android:state_focused="true" android:state_checked="false"
android:drawable="@drawable/off_focus" />
    <item android:state_focused="true" android:state_checked="true"
android:drawable="@drawable/on_focus" />



3. Detecting click on non-rectangular shapes

4. How to Check Key Status?

5. ALSA stops working sometimes

6. MediaPlayer plays sound but screen is black

7. Question about PreferenceManager.setDefaultValues