Heres a dirt simple way of doing things:
Set up a shortcut on your Android homescreen to the URL: http://<YourRaspberryPiPublicIPAddress>/androidphonehome.htm
On the Pi, running Raspbian, apt-get apache2 and you have a working webserver.
From there, the world is your oyster - you use a BASH script called from Cron every ten seconds that could monitor the Apache log looking for a particular requested URL, and perform any action based on that.
Code: Select all
ANDROID=$(tail /var/log/apache2/access.log -n 50 | grep "androidphonehome.htm" )
if [[ $ANDROID ]]
# This section is run if someone tries to visit the page mentioned above.
# Perform any action here:
# This section is run if no one visited, so do nothing.
Then have cron call /home/pi/android.sh every 2 - 60 seconds.
Of course you need a working domain name or static IP address (if you dont have either, DynDNS will work fine).
You also need security and an up to date OS when running servers exposed to the internet - at a bare minimum:
Update system software.
Set up a firewall.
Use port forwarding.
Turn off all unneeded ports and services.
NOTE: Treat the above as a starting point only. With public access to a server like that, anyone, including a search engine, could trigger your little program to run! I just wanted to show you how easy it is to get started.