4

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.

5

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.

  • 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 May 3 '11 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 Sep 28 '12 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.

  • 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 Apr 24 at 15:14
1

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

  • 1
    Can you provide more details please? – guettli May 9 '15 at 9:18
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.

New contributor
user203875 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.