登录
首页 » Android » Android Ping 分享两种网络检测方法

Android Ping 分享两种网络检测方法

于 2022-02-25 发布 文件大小:1.36 MB
0 141
下载积分: 2 下载次数: 1

代码说明:

分享给大家一个Android Ping源码。向大家演示了两种常用的android检测网络方法,在工作线程中定时执行检测网络线程,第一种方法是使用Ping,可以这样调用Process p = Runtime.getRuntime().exec("ping -c 1 -w 100 " + ip);// ping1次。用这个方法,除非Ping的网址挂了,否则用这个应该没问题;   第二种方法:判断是否有网络连接,有时连接是ok,但是网络还是不通,这个稍微麻烦下,可参考以下的代码:   ConnectivityManager mConnectivityManager = (ConnectivityManager) context    .getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();   System.out.println( "===状态===" + mNetworkInfo.getState());   System.out.println( "===类型===" + mNetworkInfo.getTypeName());   if (mNetworkInfo != null&&mNetworkInfo.getState()== NetworkInfo.State.CONNECTED) {    return mNetworkInfo.isAvailable();   }else {    return false;   } 需要完整的可编译实例源码,请下载本源码包。

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 时间管理App
    该App为了平衡学生日常的学习和休闲,设置了时间管理和计步器等功能,App通过AndroidStudio开发,适用于各种Android手机。
    2022-05-17 02:36:17下载
    积分:1
  • Android 的图像格式更改为 png 的 jpg
    此项目更改的图像格式 jpg 到 png (png 为 jpg) 第一次图像: 原始图像源 第二个图像: 它改变 jpg 低质量的压缩的格式 (质量比 3) 第三个图像: 它更改为 png 图像格式 jpg
    2022-03-06 03:26:01下载
    积分:1
  • Android Launcher 桌面分页滑动例子代码
    Android Launcher 桌面分页滑动例子代码
    2014-10-10下载
    积分:1
  • 高仿微信UI项目
    绝对是新手入门熟悉UI的项目,提升UI设计开发水平的
    2022-12-17 10:05:04下载
    积分:1
  • 安卓声音频谱分析软件
    资源描述对声音进行分析并画出频谱图。声音来自手机MIC。
    2022-11-03 04:10:03下载
    积分:1
  • 基于android的天气预报项目
    此项目是一款基于android手机的天气预报项目,能够查询全国的省份,城市,区县等,可获得不同区县的天气信息,包括温度,空气质量,建议等。开发中使用了多种开源框架,OKHttp,Glide,等。
    2023-03-08 08:10:03下载
    积分:1
  • 发送短信应用程序
    发送短信应用程序描述你如何在安卓系统发送短信。在此应用程序中,你会知道两种方法来发送短信 1) 由意图 2) 由 SMS 管理器中。
    2022-02-11 19:44:50下载
    积分:1
  • 可以联网中国象棋Android源码
    基于安卓的象棋项目源码,为联网游戏而设计的。配有java服务端,不过只能单开。我没有测试具体的功能,感兴趣的可以自己链接数据库试试吧。下面是运行指南和开发设计文档。 本源码分为客户端和服务端 客户端编译即可运行,socket连接为:127.0.0.1:9898 运行服务端时,需要使用MySQL建表,建表语句如下: create database chinachess;  use chinachess;  create table user( id int primary key auto_increment,  name char(10) unique not null, password char(16) not null, head int default 0, score int default 0, victory_count int default 0, defeat_count int default 0, draw_count int default 0, join_time datetime ) charset utf8 collate utf8_general_ci; 服务端DbUtil.java里面有连接数据库的配置 功能  1:登陆  2.注册  3.消息  4:匹配游戏  5:走棋  6:求和  7:同意求和  * 8:悔棋  * 9:同意悔棋  * 10:认输
    2022-03-11 15:32:55下载
    积分:1
  • 远程视频监控
    【核心代码】 public interface CameraSource {  static final String LOG_TAG = "camera";  /**  * Open the camera source for subsequent use via calls to capture().  *   * @return true if the camera source was successfully opened.  */  boolean open();  /**  * Close the camera source. Calling close on a closed CameraSource is  * permitted but has no effect. The camera source may be reopened after  * being closed.  */  void close();  /**  * The width of the captured image.  *   * @return the width of the capture in pixels  */  int getWidth();  /**  * The height of the captured image.  *   * @return the height of the capture in pixels  */  int getHeight();  /**  * Attempts to render the current camera view onto the supplied canvas.  * The capture will be rendered into the rectangle (0,0,width,height).  * Outstanding transformations on the canvas may alter this.  *   * @param canvas the canvas to which the captured pixel data will be written  * @return true iff a frame was successfully written to the canvas  */  boolean capture(Canvas canvas);  boolean saveImage(String savePath, String fileName); }
    2013-12-04下载
    积分:1
  • android 蓝牙发送消息实例源码下载(有注释)
    android 蓝牙发送消息实例源码下载(有注释)
    2014-08-27下载
    积分:1
  • 696518资源总数
  • 105877会员总数
  • 14今日下载