How to find out if in Car Mode (Android)?

2020-03-25 08:08发布

问题:

is it actually possible to find out via intent (or something else) if the device is currently in Car Mode? I tried to do this with a receiver that has a global variable, however I guess the variable doesn't survive after going through the onReceive ;-)

So is there another way?

Thanks!

回答1:

I got this link after googling for

Configuration UI_MODE_TYPE_CAR

. Link - http://www.java2s.com/Open-Source/Android/Samples/techbooster/org/jpn/techbooster/sample/uiModeManager.java.htm

It mentions

getSystemService(Context.UI_MODE_SERVICE).getCurrentModeType() will return Configuration.UI_MODE_TYPE_CAR if it is the case.