Last active
May 25, 2018 16:32
-
-
Save basil2style/a99afe33ba7b8df6ee95 to your computer and use it in GitHub Desktop.
This will Check Internet Connected or not
This file contains hidden or 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
| if(isOnline()){ | |
| Toast.maketext(this,"Network Connected",Toast.LENGTH_SHORT).show(); | |
| } | |
| else{ | |
| Toast.maketext(this,"No Network Connection",Toast.LENGTH_SHORT).show(); | |
| } | |
| public boolean isOnline(){ | |
| ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
| NetworkInfo netInfo = cm.getActiveNetworkInfo(); | |
| if(netInfo !=null && netinfo.isConnectedorConnecting()){ | |
| return true; | |
| }else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment