i developing the project that is uses the internet my problem is that check the application is connected to internet or not i used the fallowing code but error is generated
public void onClick(View v)
{
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info= cm.getActiveNetworkInfo();
    boolean a= cm.getActiveNetworkInfo().isConnectedOrConnecting();
    if(a==true){
        Toast("Connected");
    }
    else{
        Toast("Not Connected");
    }
}