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 !

splash1.jpg

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

splash2.jpg

without

splash3.jpg
 

Filippo

Expert
Licensed User
Longtime User
As part of this project to integrate a B4A application with Android Auto, I am faced with a major constraint: the absence of libraries compatible with B4A facilitating this integration. To overcome this challenge, I propose the creation of a proxy application developed in Java or Kotlin. This app would act as an intermediary between our B4A app and Android Auto, receiving data and notifications from our B4A app to forward to Android Auto. Realizing this solution would require the expertise of developers specialized in Java or Kotlin, skills that I do not currently possess. This will involve sending from B4A a message of the type “MESSAGE as well as its icon”. ?
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
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.
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

Active 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
Top