Siva K
Siva K

Reputation: 4968

error during the parsing activity

hi i have created a question answer based app, the question's used to be a random one based on the pictures. There was no error in the coding, the app runs successfully. It enters the main page and to second one too but when i move on to the question answer part the image is been displayed and no more further action on it, the parsing activity of my code starts here it is not going further.

when i placed a try catch block in my coding, in the logcat it showed us

02-17 14:49:20.582: ERROR/Parsing Pack(1194): Packthumb = butenemethylpropane
02-17 14:49:21.502: ERROR/(1194): orientationvalue1 width = 320 Height = 480
02-17 14:49:21.502: ERROR/(1194): 2130837515
02-17 14:49:21.502: ERROR/(1194): butene_vs_2butene
02-17 14:49:21.532: ERROR/Timerview(1194): L= 20W= 15H= 200
02-17 14:49:21.562: ERROR/ParsingActivity oncreate(1194): ERROR =     android.content.res.Resources$NotFoundException: Resource ID #0x0

the following is my coding of the parsing activity

try 
        {
            resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
            saxparserfactory = SAXParserFactory.newInstance();
            saxparser = saxparserfactory.newSAXParser();
            xmlreader = saxparser.getXMLReader();

            //getting the path of xml to parse
            inputstream = this.getResources().openRawResource(resID);

            xmlreader.setContentHandler(myXMLHandler);
            //parsing the xml
            xmlreader.parse(new InputSource(inputstream));

            //getting the values of xml
            item = myXMLHandler.getitem();
            menteon = myXMLHandler.getmenteon();
            polygon = myXMLHandler.getpolygon();
            point = myXMLHandler.getpoint();


            orientation = menteon.getOrientation();
            o = menteon.getItem().size();
            Log.e("ParsingActivity", "Orientation = "+orientation);
            Log.e("ParsingActivity", "menteon size = "+o);

            //calling function for random number
            qnumber();

            if(orientation.equalsIgnoreCase("portrait") && orientationvalue==2 )
            {
                alertportrait(orientation, orientationvalue);   
            }
            else  if(orientation.equalsIgnoreCase("landscape") && orientationvalue==1 )
            {
                alertlandscape(orientation, orientationvalue);
            }
            if(orientation.equalsIgnoreCase("portrait") && orientationvalue==1)
            {
                setRequestedOrientation(1);
                alertstart();
            }
            else if(orientation.equalsIgnoreCase("landscape")&& orientationvalue==2)
            {
                setRequestedOrientation(2);
                alertstart();
            }

        }
        catch (Exception e) 
        {
            e.printStackTrace();
            Log.e("ParsingActivity oncreate", "ERROR = "+e);
        }


}   

pls help me in debugging my error

Upvotes: 0

Views: 194

Answers (2)

Tanmay Mandal
Tanmay Mandal

Reputation: 40168

The error is coming from the line

resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");

which results the exception

android.content.res.Resources$NotFoundException

This exception is thrown by the resource APIs when a requested resource can not be found.

Please make sure that you have a resource same as specified name.

Hope this will help you.

Upvotes: 1

Nanne
Nanne

Reputation: 64409

Looking at this :

ERROR =     android.content.res.Resources$NotFoundException: Resource ID #0x0

I'd suspect you are trying to find a resource with id "#0x0", and it doesn't exist. Probably you are not requesting a real ID. I see this code that works with resources:

resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
inputstream = this.getResources().openRawResource(resID);

For debugging I would log the resID, to check what you are getting back for the first line. And checking if that is indeed the correct resource: I think that call to getIdentifier might be going wrong?

Upvotes: 2

Related Questions