protected boolean isOnline()            
{
      ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo info = cm.getActiveNetworkInfo();
      if (info != null && info.isConnectedOrConnecting()) {
        return true;
      }else
      {
        return  false;
      }
}
public void requestData()
{
    if (isOnline())
    {
        Toast.makeText(getApplicationContext(), "connected", Toast.LENGTH_LONG).show();
    }
    else
    {
        Toast.makeText(getApplicationContext(), "Niot Connected", Toast.LENGTH_LONG).show();
    }
}
I have written this code but I am getting An error something like "Unfortunately your program has stopped".. Please help me.. Thanks In Advance
 
     
     
     
     
    