Hi,
I was looking for such a function for my apps and found it at stackoverflow.
I was looking for such a function for my apps and found it at stackoverflow.
B4X:
Public Sub HasCellular As Boolean
Dim no As NativeObject = Me
Return no.RunMethod("hasCellular", Null).AsBoolean
End Sub
#If ObjC
#import <ifaddrs.h>
- (bool) hasCellular {
struct ifaddrs * addrs;
const struct ifaddrs * cursor;
bool found = false;
if (getifaddrs(&addrs) == 0) {
cursor = addrs;
while (cursor != NULL) {
NSString *name = [NSString stringWithUTF8String:cursor->ifa_name];
if ([name isEqualToString:@"pdp_ip0"]) {
found = true;
break;
}
cursor = cursor->ifa_next;
}
freeifaddrs(addrs);
}
return found;
}
#End If