I need to know if my glass has internet connectivity.
I have tried to use this solution How to check if Google Glass is connected to internet using GDK
public static void isNetworkAvailable(Context context){
HttpGet httpGet = new HttpGet("http://www.google.com");
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is established.
// The default value is zero, that means the timeout is not used.
int timeoutConnection = 3000;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = 5000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
try{
Log.d(TAG, "Checking network connection...");
httpClient.execute(httpGet);
Log.d(TAG, "Connection OK");
return;
}
catch(ClientProtocolException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
Log.d(TAG, "Connection unavailable");
}
It's work ok for my in XE 17.1 but when i have updated my Glass to XE 18.1 it's work but i need to wait until TIME_OUT to know Glass have not internet connectivity. In XE 17.1 it's not happen. If i hadn't connectivity, a exception was threw without waiting TIME_OUT.
Any idea for know internet connectivity without waiting Time out?
Thanks!