AssertionError on android.util.Xml.parse

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


Sponsored Links
 Hi,

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();
            reader.setContentHandler(contentHandler);
            InputSource source = new InputSource(in);
            source.setEncoding(encoding.expatName);
            reader.parse(source);
        } 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. To open a new image after clicking a imageButton/how to use onclick

Hii all,

I have three Image buttons as:

1.Sequences(This is an image having)
2.Videos(a video file)
3.Information(this is an image file)

    Now  what i want is that as user clicks on the imageButton
Sequences a new image should be open .when clicks on Videos, a new
video shoul be open and when clicks on Information An information
image opens.

i have tried to code something like:

package com.example.imageButton;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class imageButton extends Activity {

    private static ImageButton seqIBtn;
    private static ImageButton vidIBtn;
    private static ImageButton infoIBtn;

    // Create a button click listener for the Done button.
    private final ImageButton.OnClickListener btnDoneOnClick = new
ImageButton.OnClickListener() {
        public void onClick(View v) {
        //now how to open new images after clicking here

        }
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Get pointers to the Views defined in main.xml
        seqIBtn = (ImageButton) findViewById(R.id.btnSequence);
        vidIBtn = (ImageButton) findViewById(R.id.btnVideo);
        infoIBtn = (ImageButton) findViewById(R.id.btnInfo);
        seqIBtn.setOnClickListener(btnDoneOnClick);
        vidIBtn.setOnClickListener(btnDoneOnClick);
        infoIBtn.setOnClickListener(btnDoneOnClick);
    }
}


i am able to see my all the three images in my simulator.
Please help me

-- 

2. Create Sitemap

Hi,

There is a sitemap <http://sitemap.tejji.com/> tool which creates sitemaps
for website. Can someone test it on Android whether it is working or not

This is based on Microsoft's Silverlight Technology.

Regards,
Harshad

-- 

3. Security unlock swipe effect

4. How to speed up the Android emulator.

5. EditText

6. TranslateAnimation doesn't animate straight (X-only) but also in Y-direction (diagonal)

7. Android devices supporting OpenGL ES 2.0 (at least through NDK) as of September 2010