Android Question ANDROID-AUTO

Mr Blue Sky

Active Member
Licensed User
Longtime User
Hello everyone in the B4A community,

I'm developing an test app for Android Auto and I'm facing a few problem. My goal is to make the app viewable both on Android Auto and as a regular app on smartphones. Here is how I configured my manifest:

manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
   
<application
    android:allowBackup="true"
    android:appCategory="productivity"
    android:icon="@drawable/icon"
    android:label="android_auto"
    android:supportsRtl="true"
    android:theme="@style/LightTheme">
    <meta-data
        android:name="com.google.android.gms.car.application"
        android:resource="@xml/automotive_app_desc"/>
</application>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-feature android:name="android.hardware.type.automotive" android:required="true" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" />
<uses-feature android:name="android.hardware.screen.landscape" android:required="true" />
)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)

The installation is successful, and the application appears in "System > My applications" but not in the phone's launcher. Additionally, when I add a necessary intent-filter to the main activity for visibility in the launcher, I receive an "invalid package" error message.
Also, in both configurations, the application is not visible in the Android Auto launcher either.

Do you have any suggestions or solutions to resolve these issues? Examples of configurations that have worked for you would be much appreciated.

Thanks a lot for your help !


with
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>


without

 

Filippo

Expert
Licensed User
Longtime User
I am not familiar with Java and Kotlin.
But what I have understood is that an app for Android-Auto must be created from 2 apps (2 layouts, one for smartphone and one for Android-Auto). This is currently not possible with B4x or I don't know how it should work.

I'm still on vacation at the moment, but as soon as I'm back home, I'll start working with Android-Studio, with the hope that it will be easier/possible.
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Yes an application with Android studio which has the Android-auto libraries even a widgets which receives messages from B4A and transmits them. in this case no need to have a specific library for B4A
 
Upvote 0

fbritop

Well-Known Member
Licensed User
Longtime User
Thanks @Mr Blue Sky and @Filippo
Year ago I posted if someone was gotten any further:


It could be great in how to interact with slave devices, back in that time Google had released that IOT things were considered as part of the ecosystem of Android Auto. I never got any further with my lack of knowledge. As I did understood by that time, the car actuates as a slave App from the phone, that requiered a special layout with the restrictions that apply for.

I faced two changes by that time:
1.- How to interact with the car "keyboard", in this case the rotary knob

2.- My App is for garage remote opening, so it was quite useful to try to give commands from the car device rather than unlocking our phones to try to interact with the garage controler. In this case what I faced, was I was not quite sure how the Location works, because in my app location is only while app is in used and is in foreground. I needed the location as there is a "safety distance" between the controler and the device to be actuated. I never found and answer if the app was considered in "Foreground" when the slave has the app working.

I´ll bookmark this post as it has been the most useful post regarding slave devices.
I think this is something very needed (Also for CarPlay) as more devices functionalities are driven ny slave devices (cars, watches, etc).
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
have you tried adding these 2 to your manifest?
B4X:
<!-- Permission for media playback control -->        <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"/>        
<!-- Permission for interacting with Android Auto -->        <uses-permission android:name="com.google.android.projection.CAR_PERMISSION"/>

Recommended by chatGPT - I'm sure the Car Permission is probably needed
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
It is my understanding that Android Auto places severe restrictions on what an app can do when played in the car. I susect it is for safety reasons. An example is the Home Assistant app that in the car looks nothing like on the phone, and functionality when driving is much more limited than when stopped (you can change some settings while stopped but while driving, you are pretty much limited to displaying status and pressing buttons.)
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
"My App is for garage remote opening"
I have the same need. At the moment, this is resolved through the Home Assistant app, which is no a bad thing anyways because Home Assistant already controls a bit of my house.
 
Upvote 0

fbritop

Well-Known Member
Licensed User
Longtime User
"My App is for garage remote opening"
I have the same need. At the moment, this is resolved through the Home Assistant app, which is no a bad thing anyways because Home Assistant already controls a bit of my house.
Great,
what is the flow you applied for using Home Assistant App?
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Great,
what is the flow you applied for using Home Assistant App?
I have an MQTT based device in the gate controller that reports to HA the gate status and can be controlled via HA to move the gate. It's not working from the car yet but it's working from HA and I am close. It's just a bit of pain to debug the AA version of HA because there are a bunch of controls I don't need so those I need are buried, the names have to be short to be fully visible on AA which is not the way I have setup HA, and my gate controller is not "hacker remote control" friendly....

It's actually a bit more complicated because the gate controller is at the edge of WiFi range (a bit outside of reliable wifi range) so the gate controller has a LORA module and I have a LORA-MQTT gateway in the house that supports all the devices that are out of WiFi range (gate controller, temperature sensors, the salt chlorinator for the pool, lights, etc...) The LORA-gateway-MQTT-HA part works very well though and has been in use for several months.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…