car-samples icon indicating copy to clipboard operation
car-samples copied to clipboard

Unavailable, for your safety. This activity is not available while driving.

Open asimwaleed opened this issue 4 years ago • 4 comments

I just create sample project for android automotive OS in which i just display "Hello World" text, but the issue is when i install my apk on emulator (Polestar 2) and increase the speed (from 0 to 3, 4 any number) it shows me this text, "Unavailable, for your safety. This activity is not available while driving." I also create config.xml file in which i make my activity white listed also add meta-data tag in manifest but still got this message. Below is my config.xml and manifest.

<?xml version="1.0" encoding="utf-8"?>

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!--  Comma separated list of activities that need to be exempted from getting
          blocked in a UX restricted state.
          Format of each entry is either to specify package name to allowlist the whole package or
          use format of "packagename/activity_classname" for tagging each activities.
          For general guidelines to design distraction optimized apps, please refer
          to Android Auto Driver Distraction Guidelines. -->
    <string name="activityWhitelist" translatable="false">mypackage/mypackage.myapplication.TestActivity</string>


</resources>

--Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage.myapplication">

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />
    <uses-permission android:name="android.car.permission.CAR_POWERTRAIN" />
    <uses-permission android:name="android.car.permission.CAR_SPEED" />
    <uses-permission android:name="android.car.permission.CAR_ENERGY" />
    <uses-permission android:name="android.car.permission.CAR_UX_RESTRICTIONS_CONFIGURATION" />
    <uses-permission android:name="android.car.permission.CAR_DRIVING_STATE"/>
    <uses-permission android:name="androidx.car.app.NAVIGATION_TEMPLATES"/>
    <uses-permission android:name="androidx.car.app.ACCESS_SURFACE"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
        <activity android:name=".TestActivity"
            android:exported="true"
            android:label="e">
            <meta-data android:name="distractionOptimized" android:value="true"/>
            <intent-filter>
                <action android:name="android.intent.action.APPLICATION_PREFERENCES"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

I also tried your sample application, but the behaviour is same.

asimwaleed avatar Mar 03 '21 09:03 asimwaleed

No updates on this?

Morteza-Rastgoo avatar Jul 20 '22 13:07 Morteza-Rastgoo

No updates on this?

No update from google

asimwaleed avatar Jul 20 '22 13:07 asimwaleed

Hi; There is no update on this issue? How to tell android automotive that the app is safe to be used when driving? I have tried adding the following line to the manifest file, but it does not have any effect.

<meta-data android:name="distractionOptimized" android:value="true" />

AlirezaGhadimi avatar Sep 04 '22 05:09 AlirezaGhadimi

It looks like you need to set distractionOptimized in the manifest file and your app must be from a trusted source such as Play Store. See the SO answer : https://stackoverflow.com/questions/65668981/how-to-get-permission-for-driver-distraction-optimized

I believe the Android emulator should have a setting to allow the application based on the manifest file only.

ocihangir avatar Jul 04 '23 12:07 ocihangir