0

I wanna use a library from GitHub named "Android Network Tools", but actually I have a complex issue when using that. I tested the ping of this library on different type of devices and Android versions, and it worked correctly and was perfect, but when I tested it on my Samsung Galaxy S8 with android 8 I saw pinging external IP(like google.com) didn't work! at the first, I thought it happens in Android 8 and tried to solve it, but I launched it in Android 8 with the emulator that was ok! after that, I decided to test it on my friend's Samsung J7, you can guess that what happened, it didn't work again! Right now, I'm really really confused because of I don't know why it happens just on Samsung devices, do you have any idea?

mhadikz
  • 11
  • 2
  • 7

3 Answers3

0

The problem is not with your code , the problem is occurring because of Device manufacturers They change the Os according to there need which causes issue with ping , see

Why does ping works on some devices and not others?

Manohar
  • 22,116
  • 9
  • 108
  • 144
  • Actually, I had seen this @redman, but I think my problem doesn't relate to that because of the ping of the library worked for 3 or 4 times suddenly like other devices, but unfortunately, I couldn't understand why – mhadikz Aug 01 '18 at 14:18
0

Finally, I found the problem, this was about control running apps in the background! when that feature be enabled some methods and ping doesn't work correctly in real-time.

power saving mode

mhadikz
  • 11
  • 2
  • 7
0

Yes this is correct. With any power saving mode active, on at least some Android o/s versions, ping will not function. I'm guessing icmp echo reply packets are dropped. A sniffer app would confirm this. It is possible icmp echo (outbound) packets aren't even generated. Crazy in my view. Most ping utilities are very lightweight and I would have thought consume minimal power. I'm running a Samsung J5 / Android v.7.0. Ping started working once I disabled power saving mode