Reputation: 641
I'm working on Xamarin for Android, and i need to enable/disable the ethernet connection (RJ45 Cable), i've been looking for it from about 3 days and can't find anything that help me out with this.
Does anyone know a way to do it??
Today i found this:
http://developer.oesf.biz/em/developer/reference/durian/android/net/ethernet/EthernetManager.html
But i can't find either Java.Lang.Object nor Android.Net.Ethernet on Xamarin. Even on Eclipse i can't find it and i have the SDK updated and complete (From API 2 to API 19).
Upvotes: 4
Views: 16262
Reputation: 641
I found a way to start the ethernet using an internal command, requires Root access, but works.
Java.Lang.Runtime proc = Java.Lang.Runtime.GetRuntime();
proc.Exec(new String[]{"su", "-c", "netcfg eth0 up"});
Upvotes: 2
Reputation: 1759
Try
ConnectivityManager.Ethernet;
Class http://developer.android.com/reference/android/net/ConnectivityManager.html
ConnectivityManager Types :
Upvotes: 0
Reputation: 1759
I Think
var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
var mobileState = connectivityManager.GetNetworkInfo(ConnectivityType.Wifi).GetState();
if (mobileState != NetworkInfo.State.Connected)
{
//set your wifi on
var mawifi = (WifiManager)GetSystemService(WifiService);
mawifi.SetWifiEnabled(true);
}
Upvotes: 0