Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public boolean isConnectingToInternet(){
  2. ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  3. if (connectivity != null)
  4. {
  5. NetworkInfo[] info = connectivity.getAllNetworkInfo();
  6. if (info != null)
  7. for (int i = 0; i < info.length; i++)
  8. if (info[i].getState() == NetworkInfo.State.CONNECTED)
  9. {
  10. return true;
  11. }
  12.  
  13. }
  14. return false;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement