O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Networking

Many Android applications transfer data between the device and a server, or between devices. Like the battery state, applications may need to retrieve information about the network connections on the device. The ConnectivityManager class provides APIs applications can call to have access to the network information. Android devices often have multiple data connections available:

  • Bluetooth
  • Ethernet
  • Wi-Fi
  • WiMAX
  • Mobile (EDGE, UMTS, LTE)

Listing 7–6 shows how to retrieve information about the active connection as well as all the connections.

Listing 7–6. Network Information

    private void showNetworkInfoToast() {         ConnectivityManager cm = (ConnectivityManager)             getSystemService(Context.CONNECTIVITY_SERVICE);         // ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required