I can give you a basic idea with my Multiplayer Fingerboard game.
I assume you have a database with a table containing your user data.
When a player logs in I set a boolean flag to 'online' for example.
Now your game queries your server at a set interval (every 5 seconds in my case) to see who's online and returns their status.
I suppose in your game you need to know each players real time map coordinates, name, health, score, etc... from another table storing this information.
Also you need to know when a player logs out or quits without properly logging out.
In my game each time a players device queries the server I make a timestamp. If they have not queried within the last 10 seconds then they are considered offline.
Just some ides. My game is a very basic turned based game.
Your welcome to download the apk directly and check out the code:
http://www.appzumbi.com/developers/wazumbi/app_106/fingerboardOrDie.apk
It's not commented and I'm not sure if this is the most efficient approach but maybe it will help.