Saturday 15 January 2011

android - Cant Connect to XML WebPage, Using SAX Parsing -


When I try to connect to the follwing webpage in my Android project , and to get data paras. My application crashes, I do not understand what I'm leaving.

Here is the snippet of the parsing file. Case RID.BCine: String e = Email.Gate Text (). ToString (); // Receive email from login page String P = password .gettext (). ToString (); // Receiving a password from the login page StringBuilder URL = New StringBuilder (baseURL); URL.append (e + "& amp; password =" + P); String fullUrl = URL.toString (); New loadURL () Execute (full url); break;

What my insect cookies I'm using

  protected class loadURL AsyncTask & lt; String, zero, intent & gt; {Protected intention doInBackground (string ... full url) {return xmlParsing (fullUrl [0]); } Secure zero on the pistexate (intent of intent) {startActivity}; Initial activity (new intent (log in page. This, invalid user category)); }}   

Here is the xmlParsing method, which is called from my AsyncTask

  Secure gut xmlParsing (string url) { Intent activity = new intent (); {Try the URL login page = new URL (url); // Getting the XML Reader / ** * The Pars (SAF) method of the SAXParser class reads the content * SAXParserFactory is a factory API that enables applications to configure and obtain SAX parser to parse API documents. * The StartElement () method retrieves all the initial elements and prints them on the console. Whenever there is an error, * throws SAXException * / SAXParserFactory SPF = SAXParserFactory.newInstance (); SAXParser sp = spf.newSAXParser (); XMLReader xr = sp.getXMLReader (); Handling Logging Page = Works = New Handling Login Page (); Xr.setContentHandler (doingWork); Xr.parse (new input source (login.page.openstream ())); Logs. I ("info", doingWork.code ()); If ((doingWork.userInformation ()) == true) {activity = new intent (login page. This, homescreen. Square); } Other activity = new intent (login page, this is the invalid user); } Hold (exception E1) {e1.printStackTrace (); Title.setText ("Error"); } Return Activity; }   

Here handling login page

  import org.xml.sax.Attributes name is the default handler class; Import org.xml.sax.SAXException; Import org.xml.sax.helpers.DefaultHandler; Import android.content.Intent; Public category handling login page default handler {String defineCode = null; Boolean user = wrong; @ Override throws the SAXException (if the localName.equals ("code")) {defineCode = attributes.getValue ("data"); if (defineCode. Equals ("IP")} {user = false;} and if (defineCode.equals ("LS")) user = true;}} protected boolean user information () {return user; on anybody you main yuri thread on Android Network actions can not be performed.}}    

  & lt; Usage-permission Android: name = "android.permission.INTERNET" />    

No comments:

Post a Comment