I am trying to run a webservice that return XML format but it sometimes throws FileNotFoundException on 3G network and sometimes works successfully on WIFI network
here is the code of the connection :
@Override
protected ArrayList<NewsItemVO> doInBackground(Void... args) {
try {
URLConnection conn = new URL(feedUrl).openConnection();
conn.setConnectTimeout(20000);
conn.setReadTimeout(20000);
InputStream in = new BufferedInputStream(conn.getInputStream());
}
}
and this is the line that throws the exception
InputStream in = new BufferedInputStream(conn.getInputStream());
Before using input stream you could check if it is available or not?
http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html