AndroidKeysCredentials

Securing Communications on Android

With all the recent data breaches, privacy has become an important topic. Almost every app communicates over the network, so it’s important to consider the security of user information. In this post, you’ll learn the current best practices for securing the communications of your Android app.

Use HTTPS

As you are developing your app, it’s best practice to limit your network requests to ones that are essential. For the essential ones, make sure that they’re made over HTTPS instead of HTTP. HTTPS is a protocol that encrypts traffic so that it can’t easily be intercepted by eavesdroppers. The good thing about Android is that migrating is as simple as changing the URL from http to https

In fact, Android N and higher versions can enforce HTTPS using Android’s Network Security Configuration.

In Android Studio, select the app/res/xml directory for your project. Create the xml directory if it doesn’t already exist. Select it and click File > New File. Call it network_security_config.xml. The format for the file is as follows:

To tell Android to use this file, add the name of the file to the application tag in the AndroidManifest.xml file:

Powered by WPeMatico

Leave a Comment

Scroll to Top