/**
* Simple network connection check.
*
* @param context
*/
private void checkConnection(Context context) {
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
Toast.makeText(context, "网络错误", Toast.LENGTH_LONG).show();
Log.e(TAG, "checkConnection - no connection found");
}
}
关于在Android上检测是否存在网络的问题
最新推荐文章于 2023-11-27 18:00:00 发布