use of android.net.NetworkInfo in project superCleanMaster by joyoyao.
the class AppUtil method isMobile.
/**
* 判断当前网络是否是移动数据网络.
*
* @param context the context
* @return boolean
*/
public static boolean isMobile(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
return true;
}
return false;
}
use of android.net.NetworkInfo in project nmid-headline by miao1007.
the class NetworkUtils method isNetworkAvailable.
public boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
use of android.net.NetworkInfo in project packer-ng-plugin by mcxiaoke.
the class MainActivity method addNetworkInfoSection.
private void addNetworkInfoSection() {
StringBuilder builder = new StringBuilder();
builder.append("[Network]\n");
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
if (info != null) {
builder.append(info);
}
builder.append("\n\n");
addSection(builder.toString());
}
use of android.net.NetworkInfo in project Android-Boilerplate by hitherejoe.
the class NetworkUtil method isNetworkConnected.
public static boolean isNetworkConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
}
use of android.net.NetworkInfo in project Android by hmkcode.
the class MainActivity method isConnected.
public boolean isConnected() {
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected())
return true;
else
return false;
}
Aggregations