5

I'm trying to develop an application that knows when I am home based on my phone being on my wifi network or not. I'm running into a weird issue in that I can only ping the phone if I have recently (within the last minute or so) tried to access a web page on the machine I am pinging on. I'm not even able to get an ARP reply unless I've tried to recently access the machine.

So, do Android phones have a very restrictive firewall by default? Is there any way that I can change this?

I don't believe it to be a network issue, because I can ping the phone at any time from my router, it just doesn't respond to other clients on the network.

6 Answers 6

6

I believe this is simply because Android puts the Wifi to sleep to save power when the screen is turned off. You can try setting the Wifi Sleep Policy: Settings > Wireless & Network Setting > Wifi Settings > Press Menu button > Advanced > Wifi sleep policy to Never and see if your problem still persists.

Alternatively though, instead of having your server ping your phone, I think it will be easier for the phone to "ping" (or make a HTTP request or through other methods) the server when it is connecting to your Wifi network. Your application can register to the system to receive a broadcast Intent when certain Wifi events occurred.

2
  • Yes, that was it. I was trying to avoid having an application running on the phone, because I really don't like writing code in Java. It seems it may be necessary though.
    – devicenull
    Commented May 3, 2011 at 3:32
  • You could use Tasker or Locale instead of writing your own app. Both allow you considerable flexibility in setting up rules, which could include making an http request to your server when in range of your wireless network.
    – TomG
    Commented Sep 28, 2012 at 1:45
1

If you have Droidwall, allow access to "(kernel) - Linux Kernel".

On my phone this is definitely the reason why Android answers or not to a ping or tracert.

1
  • The fromer "Droidwall" App is now renamed or developed as AFWall. And yes putting the check mark for WiFi column at "(kernel) - Linux Kernel" solved it also for me.
    – linolino
    Commented Apr 24, 2019 at 15:14
0

I've been experiencing this still with Android Q still today (2019). I'm going to go with an IFTTT solution using webhooks to send the REST command I need sending. My original script was written such that I checked when my phone was "away" over the course of a minute. If it came back "home" within that time I wouldn't flip the security cameras on. Now, I'll have to shift that programming to a different type of device (Universal Devices ISY). The timer feature is important as a phone may need to be rebooted, etc.

0

Solved: need to make the phone aware is on a lan network. Install a whatever network management app "Ip Tools" and click on "Lan scanner" you will see all the other devices connected in the network, and now check again ping will works!

0

I have the same issue with my Android device that runs Android 11 only. I don't know if this is Android 11 issue or my new phone issue.

On other devices that runs Android 10, I never have problem.

I've to install PingTool to ping my PC first so that the PC will have the ARP entry of that device. I really don't like this.

Because of this, it gives extra step to connect Android Studio to that device through ADB.

-1

Android doesn't accept connection from ip addresses missing in arp cache. I think that's a bug.

1
  • 1
    Can you provide more details please?
    – guettli
    Commented May 9, 2015 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .