Richard Rose
Richard Rose

Reputation: 109

Sending a notification to the server when the android app if closed

I have created an application which is used to locate other people and a server... Now if anyone closes an app by Advanced Task Killer (This app is used to kill un-necessary application) how do i send a notification or a message to the server saying this person has closed the app. example:- I have an app which detects other peoples location. And 2 more friends of mine have it. There is a server which examines our location. Now if one of my friend closes the app as said above how do i send a message or notification to the server created.

Upvotes: 0

Views: 342

Answers (3)

P Srinivas Goud
P Srinivas Goud

Reputation: 896

Before callling finish(); (if ur calling) or in onDestory(); send "closed" as request parameter to your server url like "http:YOUR_SERVER_URL/?status=closed" using HttpClient post request.

at server catch it as request.getparamer("status");//Its JSP code

if you want inform ur frends about this use C2DM as push notification.

Upvotes: 2

MBX
MBX

Reputation: 828

Take a look at the activity life cycle. I think what you are looking for, is to call the server in the onDestory() in the current activity...

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006614

how do i send a notification or a message to the server saying this person has closed the app

You don't. If the user force-stops your app, you do not get control.

Upvotes: 1

Related Questions