Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

My app needs to send some data to a server when the device is connected.

I have been reading about native Android Broadcast actions. I was willing to find a way to use one as gmail does when the device connects to the Internet. (The "loading" icon on the top while it syncs mails)

Is it ACTION_SYNC what I am looking for?

If not, how does gmail knows when the device connects to internet?

like image 636
Macarse Avatar asked Feb 18 '10 02:02

Macarse


People also ask

How is data transferred over the internet?

Data sent over the internet is called a message, but before messages get sent, they're broken up into tinier parts called packets. These messages and packets travel from one source to the next using Internet Protocol (IP) and Transport Control Protocol (TCP).

Can IoT device send data to server?

We can connect to a web server running on our IoT device by entering the IP address of http://192.168.1.45 into the browser url. The connection will be made in this case via the switch built into the home router. The switch knows what port the IoT device is connected to and transmits and receives data via this port.

How do it Sensor transfer the data to the internet?

The sensors/devices can be connected to the cloud through a variety of methods including: cellular, satellite, WiFi, Bluetooth, low-power wide-area networks (LPWAN), or connecting directly to the internet via ethernet.

How do I connect to Internet server?

Connect the server to your router and connect the router to the modem. NOTE: After ensuring that you have an active Internet connection, connect the modem to the router's Internet port and the server to any of the four Ethernet ports on the router's back panel using an Ethernet cable.


1 Answers

You need to register a receiver like this:

    <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).

like image 188
yanchenko Avatar answered Sep 30 '22 20:09

yanchenko