Wednesday, March 16, 2011

[android-developers] Network connection issue..

I have a ListView that updates periodically from server.

The first time it loads properly...
url: http://myip/abcd?as=&scrip=abb,acc,rolta

next time, the url becomes

url: http://myIp/abcd?as=2011-03-16%2014:00:00&scrip=abb,acc,rolta
.....(a)

as I update the URL dynamically:
url = "http://myIP/abcd?as="+ASOF + "&scrip=abb,acc,rolta";

Initially, String ASOF = "";
The 2nd time, it becomes a data as mentioned in (a)

If everytime I keep ASOF="", then there is no problem....

The exception i get it java.io.FileNotFoundException...

The code is as below:
try{

URL url = new URL(url1);
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "text/html");
dis = new DataInputStream(conn.getInputStream());
//br = new BufferedReader(new
InputStreamReader( conn.getInputStream() ));

int ch = ' ';
while( (ch = dis.read()) !=-1 ){
data += String.valueOf((char)ch);
}

//br.close();
dis.close();
}catch(Throwable ex){
Log.e("error: ConnectServer", ex.toString());
try{
//br.close();
dis.close();
}catch(Exception e){

}
}

Any idea???

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment