'Ping doesn't work on Samsung Devices

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?



Solution 1:[1]

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?

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manohar
Solution 2