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?
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).
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With