Back to project page Dialog4Android.
The source code is released under:
Copyright (c) 2014, Calvin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redis...
If you think the Android project Dialog4Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * @Title: CommonUtils.java// www. ja va 2 s . c o m * @Description: TODO * @author: Calvinyang * @date: Nov 29, 2013 11:55:09 AM * Copyright: Copyright (c) 2013 * @version: 1.0 */ package cn.edu.fudan.calvin; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.DisplayMetrics; /** * @author: Calvinyang * @Description: TODO * @date: Nov 29, 2013 11:55:09 AM */ public class CommonUtils { private static DisplayMetrics dm; /** * ???????????? * * @return */ public static boolean isNetworkConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isAvailable(); } /** * * @Title: getWidth * @Description: ?????????? * @param context * @return */ public static int getWidth(Context context) { if (dm == null) { dm = context.getResources().getDisplayMetrics(); } return dm.widthPixels; } /** * * @Title: getDensity * @Description: ????????? * @param context * @return */ public static float getDensity(Context context) { if (dm == null) { dm = context.getResources().getDisplayMetrics(); } return dm.density; } /** * * @Title: getHeight * @Description: ?????????? * @param context * @return */ public static int getHeight(Context context) { if (dm == null) { dm = context.getResources().getDisplayMetrics(); } return dm.heightPixels; } }