-
网络、异步线程相关的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());
}
- 上一篇: 理查德·克莱得曼钢琴曲全集(8CD)喜欢的收藏一下
- 下一篇: 灰鸽子易语言源码