0

I am using the following url to login into the android application

http://182.18.133.88/php/gprs_request.php?cmd=balance&username=xxxxx&password=xxxxx.

whenever i am calling this url in web browser the return xml is like this.

<time>27.01.2014 11:54:54 AM</time>
<result>true</result>
<message>
Your Credit Current Balance is 100.00. Please Recharge Soon.
</message>
</root> 

So that i am parsing this particular xml file using sax parser.suppose if the result is true the user should login into application.It works perfectly in Android 4.0 and above.i tested it in 4.1.2 it works fine but i run this application in android 2.3.6 device it gets the following system error logs.

01-27 11:46:03.562: W/System.err(18991): java.io.FileNotFoundException: http://182.18.133.88/php/gprs_request.php?cmd=balance&username=RTxxxx&password=yyyy=balance&username=RTxxxx&password=yyyy
01-27 11:46:03.570: W/System.err(18991):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521)
01-27 11:46:03.570: W/System.err(18991):    at java.net.URL.openStream(URL.java:645)
01-27 11:46:03.570: W/System.err(18991):    at com.androidapp.paraservices.common.WebserviceCall.doInBackground(WebserviceCall.java:51)
01-27 11:46:03.570: W/System.err(18991):    at com.androidapp.paraservices.common.WebserviceCall.doInBackground(WebserviceCall.java:1)
01-27 11:46:03.570: W/System.err(18991):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-27 11:46:03.570: W/System.err(18991):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
01-27 11:46:03.570: W/System.err(18991):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
01-27 11:46:03.570: W/System.err(18991):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
01-27 11:46:03.578: W/System.err(18991):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
01-27 11:46:03.578: W/System.err(18991):    at java.lang.Thread.run(Thread.java:1019)
01-27 11:46:03.578: D/LOGINACTIVITY(18991): result:false
01-27 11:46:03.601: W/InputManagerService(1511): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@409b4e70

i am calling and parsing the url like this from android code.

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
URL sourceUrl = new URL(params[0]);

LoginHandler myXMLHandler = new LoginHandler(getApplicationContext());
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));

I don't know exactly what's happening and all.Please give me the forward step to complete the thing.thanks in advance.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
malli
  • 642
  • 2
  • 12
  • 30
  • Check this thread and see if it helps: http://stackoverflow.com/questions/9365829/filenotfoundexception-for-httpurlconnection-in-ice-cream-sandwich – Kumar Bibek Jan 27 '14 at 06:53
  • You should ensure that You can connect to http://182.18.133.88/php/gprs_request.php?cmd=balance&username=xxxxx&password=xxxxx. by your phone or your emulator. Check your permission in Android Manifest and check your URL – Luc Jan 27 '14 at 07:03
  • hi jack,permission is added to manifest.but the thing is i enter that url from android 2.3.6 browser it gives the result like string.when i enter url from web browser and android 4.1.2 browser it gives the result like xml what i shared with you. – malli Jan 27 '14 at 07:29

2 Answers2

0

AFAIK when the web server returns 404, a FileNotFoundException happens.

My first thought is to try a different URL, e.g. google, and see if at least something is returned. (it will be either 404/FileNotFoundException again, or it will pass that point.)

UPDATE: with your URL, I'm getting:

$ curl http://182.18.133.88/php/gprs_request.php?cmd=balance&username=RTxxxx&password=yyyy=balance&username=RTxxxx&password=yyyy
[1] 29354
[2] 29355
[3] 29356
[4] 29357
[2]   Done                    username=RTxxxx
$ <?xml version="1.0" encoding="UTF-8" ?>
<root><time>27.01.2014 13:03:32 PM</time>

<result>false</result>
<message>Username Not Provided</message>
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127
  • whenever i am calling "www.google.com" url instead of my url,it doesn't get file not found exception.i think its calling and gets the parsing exception.what can i do for my problem. – malli Jan 27 '14 at 07:06
0

It looks like you've garbled the request arguments in the URL you are actually using ... according to the log message.

http://182.18.133.88/php/gprs_request.php?cmd=balance&username=RTXXXX&password=YYYYcmd=balance&username=RTXXXX&password=YYYY

The username and password are repeated ....

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • But how it works in android 4.0 and above.If the problem with url means it doesn't work anywhere.Anyways i tested it after your suggestion and i printed the url before calling it displays the correct url. – malli Jan 27 '14 at 07:15
  • sorry stephen,i think that is other logcat.just now i checked once again but it displays the single username and password.. – malli Jan 27 '14 at 07:35
  • Please print the URL on both Android versions and post it here. I'm getting ` false Username Not Provided ` with your URL in curl. – 18446744073709551615 Jan 27 '14 at 07:36