Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. private boolean isWiFiInetPresent() {
  2. ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
  3. return cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
  4. }
  5.  
  6. private boolean isMobileInetPresent() {
  7. boolean bRes=false;
  8. ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
  9. NetworkInfo activeNetwork=cm.getActiveNetworkInfo();
  10. if (activeNetwork!=null) {
  11. if (activeNetwork.getType()==ConnectivityManager.TYPE_MOBILE) {
  12. if (activeNetwork.isConnected()) bRes=true; //Есть инет
  13. }
  14. }
  15. return bRes;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement