1
I need to collect internet usage information on iphone , the code c# below that I am using only returns me zeroed values.
I’m using the right class ?
has some reference I need to add on Xamarin ?
in the mono appears me 3 types of classes , concidently the interface "Macosipv4interfacstatics" returns fixed always the value 0.
- Win32ipv4interfacstatics
- Linuxipv4interfacestatistics
Macosipv4interfacstatics
using System; using System.Net; using System.Net.NetworkInformation; using System.Runtime.InteropServices; using System.Threading; using MonoTouch.ObjCRuntime;
namespace Taximetro { public delegate void Update();
public static class ControleUso { public static long controller; public static long BytesReceivedWiFi; public static long BytesSentWiFi; public static long BytesReceived3G; public static long BytesSent3G; public static Update UpdateMethod; public static void DoWork() { foreach (var netint in NetworkInterface.GetAllNetworkInterfaces()) { var stats = netint.GetIPv4Statistics (); //WiFi //if (netint.Name.StartsWith ("en")) { BytesReceivedWiFi += stats.BytesReceived; BytesSentWiFi += stats.BytesSent; //} //3G if (netint.Name.StartsWith ("pdp_ip")) { BytesReceived3G += stats.BytesReceived; BytesSent3G += stats.BytesSent; } } controller++; if (UpdateMethod != null) { UpdateMethod (); } Thread.Sleep (1000); } }
}
Replied via the link http://stackoverflow.com/questions/26256093/how-to-collect-data-usage-information-from-the-internet-to-iphone-with-xamarin
– rcaratchuk
Bring the answer here. Post as an answer and accept it.
– Maniero