1

Is it possible to get notified (e.g. through a broadcast receiver) when the phone gets connected to Android Auto? We know that it is possible through the CarConnection API however it requires us to have the activity or at least a service constantly running as the subscription requires a context.

So basically we are looking for something like a Manifest-declared broadcast receiver so that our app doesn't need to run in the background. Unfortunately they're not available since Android 8 anymore (in case they're not exempt from the rule). We already considered using a Bluetooth / USB Broadcast receiver to detect if Android-Auto is connected but that seems way to unstable and hacky.

Background: We want to extend our Weather and Radar app so that as soon as the driver connects his phone we check for severe weather warnings in his area.

David Luhmer
  • 75
  • 1
  • 4

1 Answers1

0

I believe CarConnection is the way to achieve this, since it includes a broadcast receiver under the hood. If you don't want to use that API, probably you could create your own broadcast receiver like it is done in CarConnectionTypeLiveData.

By the way, there is a similar question here: How to detect if Android Head Unit is connected to Android Auto

narko
  • 3,645
  • 1
  • 28
  • 33
  • My question is different as I am looking for a solution that doesn't require the app to run in the background. Your solution requires that the app is constantly running (e.g. as a background service). The solution I'm looking / asking for would be a manifest declared receiver that would use an implicit broadcast that is exempt from the background execution limits: https://developer.android.com/guide/components/broadcast-exceptions – David Luhmer Aug 25 '23 at 08:58