Android internet connectivity issue
<p>I have developed one android app which uses web service to get data. it means it requires an internet connection. My Problem is when the internet is not available during web service call or before web service call it should throw some alerts.</p>

<p>I have implemented one code:</p>

<pre><code> public static boolean isOnline(Context context) {
        try {
        ConnectivityManager cm = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (cm.getActiveNetworkInfo().isConnectedOrConnecting()) {
        URL url = new URL("https://widget.istockanalyst.com/WebServiceIStock.asmx");
        HttpURLConnection urlc = (HttpURLConnection) url
        .openConnection();
        urlc.setRequestProperty("User-Agent", "My Android Demo");
        urlc.setRequestProperty("Connection", "close");
        urlc.setConnectTimeout(1000); // mTimeout is in seconds

        urlc.connect();

        if (urlc.getResponseCode() == 200)
        {
            System.out.println("*********True****************");

        return true;


        } 
        else 
        {
            System.out.println("*********False****************");   

        return false;

        }
        }
        } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }
        return false;
        }
</code></pre>

<p>and after that m calling this method on my splash screen. and on emulator it is responding. but when  i perform device testing after desabling the wifi it is showing an error and app crashes.</p>

<p>Pls help me.</p>
