How to set IP Address of a Non-WiFi Enabled Android Device Programmatically? Android 5.x

610 Views Asked by At

I've looked all over for this and tried my own solutions to no effect.

Basically, I am connecting to another device via ethernet cable (it's kind of hacky, don't worry, I know!). This device cannot utilize wifi, bluetooth, etc. It MUST be via ethernet.

I am able to communicate with this device via this ethernet, but need to change the IP Address to do so.

However, I am only able to find solutions for wifi, which do not work. I'm hoping for a solution that deals more with setting the IP Address for usage with this network.

Does anyone have a suggestion?

NOTE: This is searching for a solution to do this programmatically/via code.

EDIT: For clarification, this is the attempt with WiFi. There is no WiFi Manager as Wifi is disabled for this Android device (out of necessity). The Reflection is, of course, brittle but seems to be unavoidable.

I began attempting something utilizing the ConnectivityManager and NetworkInterface, but I can't seem to piece together quite how to get to the "setting the IP stage". Mostly this is due to not being able to quite find anything that will allow your to set the IP Address beyond WifiConfiguration (Which, as I mentioned, cannot be used here).

0

There are 0 best solutions below