diff --git a/docs/html/training/auto/audio/index.jd b/docs/html/training/auto/audio/index.jd index 9144900a9d995..aa20e3a29f9b2 100644 --- a/docs/html/training/auto/audio/index.jd +++ b/docs/html/training/auto/audio/index.jd @@ -20,6 +20,7 @@ page.image=auto/images/assets/icons/media_app_playback.png
  • Provide Audio Services
  • Configure Your Manifest
  • Determine if Your App is Connected
  • +
  • Handle Alarms
  • Build a Browser Service
  • Implement Play Controls
  • Support Voice Actions
  • @@ -239,6 +240,44 @@ BroadcastReceiver receiver = new BroadcastReceiver() { registerReceiver(receiver, filter); +

    Handle Alarms

    +

    +To prevent user distraction, Android Auto media apps must not start playing audio + through the car speakers unless a user consciously starts playback (such as + when the user presses play in your app). Even a user-scheduled alarm from the + media app must not start playing music through the car speakers. + If your media app has an alarm feature, the app should determine if the phone + is in +car mode +before playing any audio. Your app can do this by calling +UiModeManager.getCurrentModeType(), + which checks whether the device is running in car mode. +

    + +

    +If the device is in car mode, media apps that support alarms must do one of the +following things: + +

    + +The following code snippet checks whether an app is running in car mode: +
    + public static boolean isCarUiMode(Context c) {
    +      UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
    +      if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
    +            LogHelper.d(TAG, "Running in Car mode");
    +            return true;
    +      } else {
    +          LogHelper.d(TAG, "Running on a non-Car mode");
    +          return false;
    +        }
    +  }
    +

    Build a Browser Service