Ethernet Connectivity through Programmatically (Android) (Rooted Device)

前端 未结 4 448
太阳男子
太阳男子 2020-12-08 08:15

I have a small issue regarding Ethernet.

My three questions are:

  1. Can we programmatically Turn-On/Off Ethern

4条回答
  •  悲&欢浪女
    2020-12-08 08:33

    Three Answeres to your above questions:

    1. Yes. You could try using ifconfig eth0 down ; ifconfig eth0 up. But i have not tested it by myself yet.
    2. Yes, but you do not have to. Android does the switching for you. If you connect to WiFi, Ethernet disables. If you are already connected to WiFi and you plug your ethernet cable into the device; you need only to disable WiFi (which you know how to) and android switches automatically to ethernet.
    3. Not so easy as you may think. I have the same problem and until now i have found only one solution which i have not yet tested. Since android runs on the linux kernel, we can use ifconfig in order to manipulate the ethernet connection.

    An explanation is hidden here: http://elinux.org/images/9/98/Dive_Into_Android_Networking-_Adding_Ethernet_Connectivity.pdf

    And the youtube video of this lecture

    http://www.youtube.com/watch?v=LwI2NBq7BWM

    And a reference on how to use ifconfig for android

    Android ethernet configure IP using dhcp

    So if you come to a possible solution, please share it!! If i will do it before you i will certenly.

提交回复
热议问题