Sending data to the server when the device is connected to the Internet

My application should send some data to the server when the device is connected.

I read about Android Broadcast's own actions. I was ready to find a way to use it as gmail when the device connects to the Internet. (The download icon at the top when synchronizing messages)

Is it ACTION_SYNC what I'm looking for?

If not, how does gmail know when a device connects to the Internet?

+6
android
source share
1 answer

You need to register the receiver as follows:

<receiver android:name=".receiver.ConnectivityReceiver" android:enabled="true"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> 

More details here: http://code.google.com/events/io/2009/sessions/CodingLifeBatteryLife.html (PDF should be enough).

+3
source share

All Articles