Assign static IP to ethernet card from OTG

2020-07-17 15:14发布

I would like to assign a static IP to an ethernet card, connected to the Android device via OTG cable. It should be done programmatically, but I can't find any reference regarding ethernet cards in android.

Any ideas?

Thank you

1条回答
闹够了就滚
2楼-- · 2020-07-17 15:32

If its a rooted device you can try with this

Process process = Runtime.getRuntime().exec(new String[] { "su", "-c", "netcfg eth0 192.168.0.123"});
process.waitFor();

And also you can use ifconfig instead of netcfg.

查看更多
登录 后发表回答