title: How to detect whether the phone connected to android auto
body: <p>I'm developing an audio player application, and I need to determine when the user's device is connected to Android Auto.</p>
  
  <p>The application features an alarm, and I want to make sure it doesn't go off while the user is driving.</p>
  
  <p>To determine whether my music-service (<code>MediaBrowserService</code>) works, I can use some flags in onCreate and onDestroy, or register <a href="http://developer.android.com/intl/ru/training/auto/audio/index.html#isconnected" rel="nofollow">reciver for "com.google.android.gms.car.media.STATUS" action</a> - but it's a bad idea because alarm clock can trigger in any time. And not only when my music-service is running. </p>
  
  <p>For alarm and I use <code>AlarmManager</code> and pending intent.</p>
  
  <p>Maybe someone faced with similar problems?</p>