文件名称:Android_开发技巧杂集_网络_半透明_异步线程
文件大小:42KB
文件格式:DOC
更新时间:2016-02-07 06:27:46
Android 开发技巧杂集 异步线程
1.检查是否有网络连接 Java代码 1. public static boolean isNetworkAvailable(Context context) { 2. ConnectivityManager cm = (ConnectivityManager) context.getSystemService( 3. Context.CONNECTIVITY_SERVICE); 4. NetworkInfo info = cm.getActiveNetworkInfo(); 5. return (info != null && info.isConnected()); 6. } public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return (info != null && info.isConnected()); }