-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,4 @@ public <T extends View> T getView(int resId) { | |
public View getConvertView() { | ||
return mConvertView; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.sloop.net.utils; | ||
|
||
import android.content.Context; | ||
import android.net.ConnectivityManager; | ||
import android.net.NetworkInfo; | ||
|
||
/** | ||
* <ul type="disc"> | ||
* <li>Author: Sloop</li> | ||
* <li>Version: v1.0.0</li> | ||
* <li>Date: 2016/3/8</li> | ||
* <li>Copyright (c) 2015 GcsSloop</li> | ||
* <li><a href="http://weibo.com/GcsSloop" target="_blank">WeiBo</a> </li> | ||
* <li><a href="https://github.com/GcsSloop" target="_blank">GitHub</a> </li> | ||
* </ul> | ||
*/ | ||
public class NetUtils { | ||
|
||
/** | ||
* 用户是否连接网络 | ||
* @param context Context | ||
*/ | ||
public static boolean isNetConnection(Context context) { | ||
final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); | ||
return (networkInfo != null && networkInfo.isAvailable()); | ||
} | ||
|
||
/** | ||
* 是否连接Wifi | ||
* @param context Context | ||
*/ | ||
public static boolean isWifiConnection(Context context) { | ||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||
if (wifiNetworkInfo.isConnected()) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.