Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Host a ping file to check for communication failure by means of string-reading call to it in a loop. Do this before launching the "Buy" function (or during the "buy" function", etc) to test communication prior to giving a chance to the grey screen to appear after confirmation.</p> <p>Alternative to reading it's contents, a timeout-default can be used. If bytes receives ≠ 0, proceed; if =0 after 8 seconds (or n-Seconds) display error.</p> <p>This will catch your "ugly grey screen" from showing, as if there's not sufficient network connectivity to complete the server-check (and thus, the transaction), you'll get an error instead of launching the store function itself.</p> <p>This is essentially a manual boolean to test for failure to communicate over the network - not just reading the presence or state of a network, as sometimes a network can be working fine, but communication over the network will be buggy or too slow to accommodate app usage/transactions/browsing/etc. This method would not need additional permissions to confirm network communication.</p> <hr> <p>Here's a rough example of the code to check if a webpage/location exists without downloading the file (saving bandwidth), bu still allowing opportunity to throw an exception or fulfill an "IF/THEN". (( Source: <a href="http://singztechmusings.wordpress.com/2011/05/26/java-how-to-check-if-a-web-page-exists-and-is-available/" rel="nofollow">http://singztechmusings.wordpress.com/2011/05/26/java-how-to-check-if-a-web-page-exists-and-is-available/</a> ))</p> <pre><code>import java.net.HttpURLConnection; import java.net.URL; public class URLUtils { public static void main(String[] args) { System.out.println(URLUtils.checkIfURLExists("http://www.google.com/")); } public static boolean checkIfURLExists(String targetUrl) { HttpURLConnection httpUrlConn; try { httpUrlConn = (HttpURLConnection) new URL(targetUrl) .openConnection(); httpUrlConn.setRequestMethod("HEAD"); // Set timeouts in milliseconds httpUrlConn.setConnectTimeout(30000); httpUrlConn.setReadTimeout(30000); // Print HTTP status code/message for your information. System.out.println("Response Code: " + httpUrlConn.getResponseCode()); System.out.println("Response Message: " + httpUrlConn.getResponseMessage()); return (httpUrlConn.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); return false; } } } </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