Android is focused on helping users take advantage of the latest innovations, while making sure users' security and privacy are always a top priority.
Pay attention to permissions
Build trust with your users by being transparent and providing users control over how they experience your app.
- Request the minimum permissions that your feature needs at this time, as well as whenever you introduce major changes to your app.
- If your app is distributed on Google Play, Android vitals tells you the percentage of users who deny permissions in your app.
- Request the permission when it's needed, rather than at app startup, such that
the permission need is clear to users. Use the
shouldShowRequestPermissionRationale()method to determine if you should explain to users why your app is requesting a permission.
- If you aren't able to design your app's flow to clearly communicate in context why the permission is requested, show an in-app explanation of how the permission request enables functionality that benefits the user.
- Keep in mind that users may select the Don't ask again option in the permission request dialog. Android respects this user choice by ignoring permission requests from the same app unless the user grants the permission in the app settings. Don't unnecessarily display an explanation in these situations.
- Gracefully degrade when users deny or revoke a permission. For example, you can disable your app's voice input feature if the user doesn't grant the microphone permission.
- If you are using an SDK or library that accesses data guarded by dangerous permissions, users will generally attribute this to your app. Make sure you understand the permissions that your SDKs require and why.
Minimize your use of location
If your app requests permission to access location, help users make an informed decision.
- If your app collects location information, explain to users how your app uses this information to deliver specific benefits to them. If your app can support its use cases without requiring any location data, don't request any location permissions.
- If your app needs to pair the user's device with a nearby device over Bluetooth or Wi-Fi, use the companion device manager, which doesn't require location permissions.
- Review the level of location granularity that your app needs. Coarse location access is sufficient to fulfill most location-related use cases.
- Access location data while your app is visible to the user. That way, users can better understand why your app requests location information.
- Design your app so that it degrades gracefully when it doesn't have all-the-time access to location. On Android 10 and higher, users can limit your app's location access to while the app is in use.
- If your app needs to retain location access for a user-initiated ongoing task
after the user navigates away from your app's UI, start a foreground
service before your app goes into the
background. You can do this in one of Android's lifecycle callbacks, such as
- Don't initiate foreground services from the background. Instead, consider launching your app from a notification and then executing the location code when your app's UI becomes visible.
Handle data safely
Note: You can read more about what's considered sensitive data in the User Data article page in the Google Play Developer Policy Center.
Be transparent and secure in how you handle sensitive data.
- Make users aware that your app collects, uses, or shares sensitive data, and explain the rationale for this data usage.
- For your app's data at rest, use Android's built-in credential encryption. For data in transit, you should use SSL for all data transmission regardless of sensitivity.
- Files that contain sensitive data should be in your app-private directory within internal storage.
- On Android 10, for files only relevant to your app, store them in the app-specific directory in the filtered view of external storage. Learn more about scoped storage.
- If you need to pass sensitive data to another app, use an explicit intent. Grant one-time data access to further restrict the other app's access.
- Even when your app is in the foreground, it's a best practice to show a real-time indication that you are capturing from the microphone or camera. For example, you can use a foreground service ongoing notification to make sure users are aware. Note that Android 9 and higher don't allow for microphone or camera access when your app is in the background.
- Jetpack offers several libraries to keep your app's data more secure. Learn more in the guides on using the Jetpack Security library and the Jetpack Preferences library.
- Always use secure network connections.
- Don't include sensitive data in logcat messages or your app's log files. Learn more about how to handle user data.
Use resettable identifiers
Respect your user's privacy and use resettable identifiers. See Best practices for unique identifiers for more information.
- Don't access IMEI and device serial number, as these identifiers are persistent.
- Only use an Advertising ID for user profiling or ads use cases. For apps in Google Play, this is a requirement. Always respect user preferences on advertisement tracking for personalization.
- For the vast majority of non-ads use cases, use a privately stored globally-unique ID (GUID), which is app-scoped.
- Use the secure settings Android ID (SSAID) to share state between the apps that you own without requiring the user to sign in to an account. Learn more about how to track signed-out user preferences between apps.