0

Does anyone know the code to change an android phone's eth0 IP address (InetAddress)?

(I know that from the command line I can do ifconfig eth0 new_ip_addr. But I'm asking about something that I can put into the source code.)

HaoQi Li
  • 11,970
  • 14
  • 58
  • 77

1 Answers1

1

There's a class called NetworkInterface but it lets you to retrieve the iface's data. I would recommend using Runtime.exec("ifconfig".... NetworkInterface -> getDisplayName() and so on ) Here is some insight on how to write Runtime.exec() in the android's environment -- Runtime.exec() : Reboot in Android?

Community
  • 1
  • 1
Sergey Benner
  • 4,421
  • 2
  • 22
  • 29