Issue
I am making an app that should change its behavior when the phone is connected to an Android Auto. It does not have any Auto capabilities and will not be marketed/submitted as an Android Auto app.
Is there a way to detect if the phone is connected to an Android Auto? I know it is possible for Auto media apps to detect their connection status via a BroadcastReceiver
registered for com.google.android.gms.car.media.STATUS
action. The documentation is not 100% clear, so will this reliably work also for all other non-Auto apps?
Solution
Edit: with Android 12, the solution doesn't work anymore and instead, it's better to use CarConnection
API documented here
I know this is an old thread but since it comes first in Google, here is the answer from another question
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;
}
}
Answered By - Pierre-Olivier Dybman
Answer Checked By - Pedro (JavaFixing Volunteer)