Right now, I want to check whether the android device can connect to another device via the net. I can use the browser to log into the internet. But when I use adb shell
to connect to the android emulator and use the ping
command to connect to the host, it fails.
kaiwii@ubuntu:~$ adb shell ping 192.168.145.136 PING 192.168.145.136 (192.168.145.136) 56(84) bytes of data. ^C
(192.168.145.136 is the host's ip!)
But when I ping 127.0.0.1, it works. So, I am definitely sure the device supports the ping command. I am just confused why it can not ping the host while I can log into the internet in the browser. What's more, anyone can show any other method to check network ability in android?
Thanks
You're connected to the internet using the phone's data connection, rather than USB via the host computer. Thus, there is no network connectivity between your device and your host. Further, as your host doesn't have a public IP address (it's behind multiple levels of NATs, at least one level being evident from the IP), it is impossible for the device to be able to ping your host via the public internet.
As to checking for network connectivity, you can try the following:
ping www.google.com
The output:
busybox ifconfig -a
The output (snipping it a bit):