Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid app fails to connect to interenet on some devices, but not others
    text
    copied!<p>I'm writing an application that has several features which use HTTPConnection to connect to the internet and download data. I have tested on several devices, but the connection inside the app seems to be hit or miss on different devices. I be;lieve that the connection did not work on Samsung devices. I'm thinking that because it is not yet an "official" licensed application, that the connection is failing. Could it be some sort of OS difference?</p> <p>The code below is supposed to connect to the internet and download words to a file. It works on some devices, but on others it ends up creating a blank file with and throwing an exception. </p> <pre><code> try{ URL url = new URL("*" + currQuickList + ".txt"); URLConnection urlConnection = url.openConnection(); urlConnection.setUseCaches(false); int i = 0; // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader( urlConnection.getInputStream())); String str; int count = Integer.parseInt(in.readLine()); int[] a = createOrderedList(count,quickListLen); int d = 0; int g = 0; while ((str = in.readLine()) != null &amp;&amp; d &lt; a.length) { // str is one line of text; readLine() strips the newline // character(s) if(a[d] == g) {words.add(str); d++; } g++; } in.close(); OutputStream fo = new FileOutputStream(dir); PrintWriter p = new PrintWriter(fo); p.print(packageWords2(words) +"\n"); p.close(); fo.close(); System.out.println("file created: "+dir); //files.add(wordText); } catch(Exception e){ e.printStackTrace(); errorDialog(e); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload