diff --git a/scp/android/app/src/main/kotlin/in/ac/nitrkl/scp/FaqActivity.java b/scp/android/app/src/main/kotlin/in/ac/nitrkl/scp/FaqActivity.java index 8f2cd3d..52ea3bd 100644 --- a/scp/android/app/src/main/kotlin/in/ac/nitrkl/scp/FaqActivity.java +++ b/scp/android/app/src/main/kotlin/in/ac/nitrkl/scp/FaqActivity.java @@ -181,6 +181,10 @@ private class SearchFetch extends AsyncTask { @Override protected String doInBackground(Object[] objects) { + if (!isInternetAvailable()) { + return null; + } + if (searchText.equalsIgnoreCase("")) { try { result = client.prepareSearch(Constants.APP_NAME, Constants.QUERY) @@ -214,4 +218,14 @@ protected void onPostExecute(Object o) { } } } + + public boolean isInternetAvailable() { + try { + InetAddress ipAddr = InetAddress.getByName("google.com"); + return !ipAddr.equals(""); + + } catch (Exception e) { + return false; + } + } }