Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
    
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

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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