diff --git a/docs/html/training/auto/audio/index.jd b/docs/html/training/auto/audio/index.jd index d183f119adefc..75974e44d1c77 100644 --- a/docs/html/training/auto/audio/index.jd +++ b/docs/html/training/auto/audio/index.jd @@ -210,6 +210,34 @@ href="https://www.youtube.com/watch?v=Q96Sw6v4ULg">
Note: The icon you provide should have transparency enabled, so the icon's background gets filled in with the app's primary color.
++It is possible to determine if your app is selected as the current media app.
+
+Android Auto broadcasts an intent with com.google.android.gms.car.media.
+STATUS action when a user connects or disconnects from a media app. The broadcast intent is
+scoped to the package name of the media app selected. You can register a broadcast receiver in your
+app, preferably in your
+MediaBrowserService implementation and listen for this intent
+and adjust advertisements, metadata, and UI buttons in your app to operate safely in a vehicle.
The broadcasted intent has a String extra media_connection_status, that
+contains either media_connected or media_disconnected string that represents
+ the current connection status.
+IntentFilter filter = new IntentFilter("com.google.android.gms.car.media.STATUS");
+BroadcastReceiver receiver = new BroadcastReceiver() {
+ ...
+ public void onReceive(Context context, Intent intent) {
+ String status = intent.getStringExtra("media_connection_status");
+ boolean isConnectedToCar = "media_connected".equals(status);
+ // adjust settings based on the connection status
+ }
+};
+registerReceiver(receiver, filter);
+
+