网络检查在 android 中有效,但在 iOS 中无效
Network check works in android but same doesn't work in iOS
我检查了NetworkManager.getInstance().getCurrentAccessPoint()是否为null来判断是否有网络连接。它很简单,在 android 中效果很好,但在 iOS 中,它总是显示错误。我怎样才能让它在 iOS 中工作。在我为此目的使用 cn1 库之前。我认为它是史蒂夫的,但使用库时,我觉得它会使应用程序变慢一些。所以我使用了下面的代码。
public static boolean check_online() {
boolean online = false;
String net = NetworkManager.getInstance().getCurrentAccessPoint();
if (net == null || "".equals(net) || net.equals(null)) {
online = false;
} else {
online = true;
}
return online;
}
@Override
protected void postExample(Form f) {
if (check_online()) {
ecc = new CategoryConnection();
ecc.egCategoryConnectionMethod(this);
- - - - - -- -
//codes
- - - - - -- -
}
}else {
noConnection = new Label("No connection");
f.add(noConnection);
}
该功能仅针对 Android/RIM 实现,因为它是设备特定的。 iOS 不提供接入点控制。
扩展部分中有一个 cn1lib,可让您检测是否存在网络连接,我想这正是您真正需要的。
我检查了NetworkManager.getInstance().getCurrentAccessPoint()是否为null来判断是否有网络连接。它很简单,在 android 中效果很好,但在 iOS 中,它总是显示错误。我怎样才能让它在 iOS 中工作。在我为此目的使用 cn1 库之前。我认为它是史蒂夫的,但使用库时,我觉得它会使应用程序变慢一些。所以我使用了下面的代码。
public static boolean check_online() {
boolean online = false;
String net = NetworkManager.getInstance().getCurrentAccessPoint();
if (net == null || "".equals(net) || net.equals(null)) {
online = false;
} else {
online = true;
}
return online;
}
@Override
protected void postExample(Form f) {
if (check_online()) {
ecc = new CategoryConnection();
ecc.egCategoryConnectionMethod(this);
- - - - - -- -
//codes
- - - - - -- -
}
}else {
noConnection = new Label("No connection");
f.add(noConnection);
}
该功能仅针对 Android/RIM 实现,因为它是设备特定的。 iOS 不提供接入点控制。
扩展部分中有一个 cn1lib,可让您检测是否存在网络连接,我想这正是您真正需要的。