Created
September 22, 2015 06:22
-
-
Save smamran/96a2640bf6633665d4e0 to your computer and use it in GitHub Desktop.
Check Whether Mobile is Connected to Network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ImageView iv; | |
iv = (ImageView) findViewById(R.id.icon); | |
iv.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
ConnectivityManager mConMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo mNetworkInfo = mConMgr.getActiveNetworkInfo(); | |
if (mNetworkInfo != null && mNetworkInfo.isConnected()) { | |
System.out.println("Yes Connected"); | |
} else { | |
System.out.println("Not Connected"); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment