cesarmax
cesarmax

Reputation: 434

how does whatsapp service gets restarted even if i force stop app?

I am running whatsapp (we could call it appX from now on) in device A. I go to manage applications -> force close so appX gets closed and i no longer see appX as running services.

Now, after 5 minutes, I send a message from another device 's appX (device B) to device A appX (the one we killed it). Here are the 2 scenarios i tested :

I know it sounds weird, and lot of people will say this is impossible, but again, this has been tested on these 2 devices.

I am trying to accomplish this same behavior, so any help will be appreciated it.

Upvotes: 29

Views: 48855

Answers (4)

herom
herom

Reputation: 2542

I don't think it's some magic what happens here! It's just Android C2DM (see: https://developers.google.com/android/c2dm/), whereas the app has a registered Receiver for incoming Push Notifications and gets awaken by this message. Android C2DM is/was available with Android 2.2, that's the reason why you can't see the same behaviour on your device with Android 2.1 up and running.

By the way: As you can see, C2DM is deprecated since June 26th, 2012. So instead of C2DM, one should use GCM (see: http://developer.android.com/guide/google/gcm/gs.html)

Useful Comment: GCM needs available internet connection. You can using any other broadcast receiver such as SMSReceiver for by passing this limitation.

Upvotes: 49

Pramod Yadav
Pramod Yadav

Reputation: 2326

its nothing magical here appX uses push notifications via android GCM platform https://developer.android.com/google/gcm/index.html in GCM the app registers for a braodcast reciever and the broadcast receiver starts the service on getting the push notification. Android GCM is dependent on google play services that are available on android 2.2 and beyond that therefore you didn't see the message on 2.1 device

Upvotes: 1

Lokesh
Lokesh

Reputation: 3334

i dont have idea about whatsApp service.

But it is possible that after force stop application, restart service of app.

i use START_STICKY service for my chatApp. i have to do same thing so i use START_STICKY service so when my app kill or force stop from setting, after few second my service get restart and i able to login to my xmpp server and get incoming message.

Upvotes: 2

bonnyz
bonnyz

Reputation: 13558

Starting from Android 3.1 (API 12), if an application is force-stopped it will not restart until the user manually runs the app again.

This will happen even if the app contains a Service or an active BroadcastReceiver.

You can find the official documentation here.

Upvotes: 13

Related Questions