Android 10

Things That Have Changed

  • There is a new Permissions model, including the new ACTIVITY_RECOGNITION and ACCESS_BACKGROUND_LOCATION permissions. The new model is explained below.

  • If your app is in the background, your app can no longer start an activity. Previously, Zendrive suggested this method to implement alerts upon receiving a collision callback. Instead, Android 10 allows notifications with full-screen intents.

  • If your app uses Support Library (SDK version 6.0.0-sl) instead of AndroidX, the SDK will continue to work normally. However, we recommend you migrate to AndroidX in the future as Google has stopped development for Support Library.

    • For SDK version 6.0.0-sl, we've changed Nullability annotations from android.support.annotation to javax.annotation. While this is a visible change, you don't need to do anything about it.

More Resources:

Permissions Model

As always, we recommend you request all necessary permissions from a user before Zendrive.setup() is called. This guarantees that you track mileage upon first use.

These are the new permissions you need:

Activity Recognition

ACTIVITY_RECOGNITION: This physical activity permission allows your app to detect a user's step count or classify their activity, such as walking, biking, or moving in a vehicle. Previously, this access was available without needing the user's consent. Therefore, for users using Android P or older, no additional permission is needed. In Android 10, users will need to grant permissions to activity data for trips to be detected when the app is in the background.

You can query for missing physical activity permissions within the Settings API.

Background Location

ACCESS_BACKGROUND_LOCATION: This permission allows your app to access location information while in the background. It is new in Android 10 and must be requested separately from ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION. In the following image, "Allow all the time" will grant both background and fine location. "Allow only while using the app" will grant fine location and deny background location. "Deny" will of course, deny both.

If a user grants background location access, the system may occasionally deliver a reminder notification to the user to review the permission.

For devices running Android 10, the system insists your app requests for this permission if it asks for location access, even if your app targets Android P or older. This means that if you request fine or coarse location, the system will automatically add background location to that request.

F.A.Q.

When do I need to request for ACTIVITY_RECOGNITION permission?

If your app targets Android 9 (API level 28) or lower and specifies the com.google.android.gms.permission.ACTIVITY_RECOGNITION permission in its manifest file, the system auto-grants this permission to your app if needed.

When you update your app to target Android 10, the platform retains the permission. However, the user can revoke this permission at any time in system settings.

Starting with SDK 6.0, we will provide an error that indicates if the permission has not been granted.

You can use the following table for reference:

Headers

New User on Android 10

Existing User Upgrades to Android 10

Zendrive SDK >= 6.0 Target SDK Version = 29

  • SDK provides error.

  • Permission is needed.

  • SDK provides error.

  • Permission is retained.

Zendrive SDK < 6.0 Target SDK Version < 29

  • SDK does not provide error.

  • Permission is auto-granted.

  • SDK does not provide error.

  • Permission is retained.

Zendrive SDK < 6.0 Target SDK Version = 29

  • SDK does not provide error.

  • Permission is needed.

  • No trips detected

  • SDK does not provide error.

  • Permission is retained.

  • Since a user may manually change settings in Android 10 or above, you should warn them that the ACTIVITY_RECOGNITION permission (shown as Physical Activity) is needed to detect trips correctly. SDK 6.0 provides an error via the onZendriveSettingsConfigChanged API if permissions are missing.

  • If the user is not on Android 10 and above, the permission is automatically granted and no action is needed.

Was this helpful?