HaoQi Li
HaoQi Li

Reputation: 12348

Code to change Android's IP address/InetAddress?

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.)

Upvotes: 0

Views: 1716

Answers (1)

Sergey Benner
Sergey Benner

Reputation: 4431

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?

Upvotes: 1

Related Questions