Chieftan
Chieftan

Reputation: 11

Android ICS 4.1 - USB Ethernet - How to toggle Ethernet connectivity state?

I purchased an android device (Rikomagic MK 802IIIs) to connect to my TV. I have developed a simple application that requires an internet connection (currently connected via a USB Ethernet adapter).

My issue is that the Ethernet connection is found (MAC Address has been set) however my IP and other details are not configuring on boot (0.0.0.0).

If I toggle the Ethernet state, it picks up the details and everything works fine again.

I believe that the issue may be due to the device, so I was wondering if anyone knows of how I could 'Toggle' the Ethernet connectivity via code.

I have an application that executes on boot so essentially I will be placing it there.

Thanks.

Upvotes: 1

Views: 3309

Answers (1)

Silas
Silas

Reputation: 1150

I had the same problem with my Android HDMI TV stick. Because it wasn't my intention to write an own app for this I had a look at scripting possibilities.

Running dhcpcd eth0 in a root terminal first seemed to work but caused Android's settings app to crash. So I set up a static IP in Android's ethernet settings and just disable and enable the device by running ifconfig eth0 down ; ifconfig eth0 up. This works reliably.

To run this command every time after boot with su privileges I use SManager.

I don't know if this is a solution for you but if not you could toggle ethernet state simply by executing ifconfig eth0 up and ifconfig eth0 down with root privileges from your own app:

Upvotes: 1

Related Questions