Skip to content

Most visited

Recently visited


Inspect Network Traffic with Network Profiler

The Network Profiler displays realtime network activity on a timeline, showing data sent and received, as well as the current number of connections. This lets you examine how and when your app transfers data, and optimize the underlying code appropriately.

To open the Network Profiler, follow these steps:

  1. Click View > Tool Windows > Android Profiler (you can also click Android Profiler in the toolbar).
  2. Select the device and app process you want to profile from the Android Profiler toolbar. If you've connected a device over USB but don't see it listed, ensure that you have enabled USB debugging.
  3. Click anywhere in the NETWORK timeline to open the Network Profiler.

To select a portion of the timeline, inspect a list of network requests sent and responses received, or view detailed information about a selected file, you must enable advanced profiling.

Why you should profile your app's network activity

When your app makes a request to the network, the device must use the power-hungry mobile or WiFi radios to send and receive packets. The radios not only use power to transfer data, but also use extra power to turn on and to stay awake.

Using the Network Profiler, you can look for frequent, short spikes of network activity, which mean that your app requires the radios to turn on frequently, or to stay awake for long periods to handle many short requests close together. This pattern indicates that you may be able to optimize your app for improved battery performance by batching network requests, thereby reducing the number of times the radios must turn on to send or receive data. This also allows the radios to switch into low-power mode to save battery in the longer gaps between batched requests.

For more information about techniques to optimize your app's network activity, read Reducing Network Battery Drain.

Network Profiler overview

At the top of the window, you can see the event timeline and 1 radio power state (high/low) vs Wi-Fi. On the timeline, you can 2 click and drag to select a portion of the timeline to inspect the traffic.

Figure 1. The Network Profiler window

In the 3 pane below the timeline, select one of the following tabs for more detail about the network activity during the selected portion of the timeline:

From either the Connection View or Thread View, click a request name to inspect 4 detailed information about the data sent or received. Click the tabs to view the response header and body, request header and body, or call stack.

URL url = new URL(MY_URL_EN);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
// Sets acceptable encodings in the request header.
urlConnection.setRequestProperty("Accept-Encoding", "identity");

Network connection troubleshooting

If the Network Profiler detects traffic values, but cannot identify any supported network requests, you will receive the following error message:

"Network Profiling Data Unavailable: There is no information for the network traffic you've selected."

Currently, the Network Profiler supports only the HttpURLConnection and OkHttp libraries for network connections. If your app uses another network connection library, you may not be able to view your network activity in the Network Profiler. If you have received this error message, but your app does use HttpURLConnection or OkHttp, please report a bug, or search the issue tracker to include your feedback in an existing report that's related to your issue. You can also use these resources to request support for additional libraries.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)