Google Assistant not opening in foreground Android v12

Hello,

I've built an app that calls the Google Assistant on a button push from Arduino. It's working fine on Android 8, you push the button on the Arduino and the Google Assistant toast springs up in the foreground, not matter which app is currently in the foreground. IE the MIT App Inventor app (My App) doesn't need to be in the foreground.

But on Android 12 you push the button and the Google Assistant toast only springs up when My App is in the foreground, the Arduino button push works if My App is in the background and when My App is brought to the foreground the Google Assistant toast then springs up waiting for the voice commands.

Below are the blocks I'm using any ideas would be most appreciated, I think it might be something to do with the manifest and declaring the apps I'm going to use with the intents, but I'm not sure? I have tried some edits to the manifest without success.

Thanks Ian

Can you please show the full content of Activity Class...

As requested;

Action = android.intent.action.VIEW
ActivityPackage = com.google.android.apps.googleassistant
ActivityClass = com.google.android.apps.googleassistant.AssistantActivity

1 Like

Hmmm - I am getting error 601 no corresponding activity back on my Android 12 using companion

I'm using an S20, It's working for me on the companion and installed, the Android 8 is an A3.

Even if I can get My app to come to the front and then fire the Google Assistant that, will probably solve my issue, but having the Google Assistant toast spring up on it's own would be best.

Here's the manifest,

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="Aston_Sat_Nav_Silver_02" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:configChanges="keyboardHidden|orientation" android:name="com.google.appinventor.components.runtime.ListPickerActivity" android:screenOrientation="behind"/>
    <provider android:authorities="appinventor.ai_ianway1969.Aston_Sat_Nav_Silver_02.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
</application>

Perhaps I need to compile ? No that doesn't work either.

That's strange How do I, share my project with you?

I have the developer options enabled.

Going to call it a day for today, been at it all afternoon & the Mrs is getting annoyed.

Be back online tomorrow.

1 Like

Found a set that works:

but again only when my app is running in the foreground...

Action = android.intent.action.VOICE_COMMAND
Package = com.google.android.googlequicksearchbox
Class = com.google.android.apps.gsa.staticplugins.opa.EnterOpaActivityFromDeeplink

Did some digging and come up with the following,

Looks like it could be something to do with V12, I've only been creating Apps for a few weeks so I'm not entirely sure if these links are relevant or how to go about resolving the issue.

Also I tried it on the emulator and also got a 601 error, do you know which version of Android the emulator uses?

Thanks

The emulator will probably not run this activity...

Yep,

I went all the way down to V8 on android studio emulator and got error 601 every time.

I've thought of a work around but it depends on the App being able to send a broadcast to start an Automate flow, can a MIT App Inventor App send a broadcast?

You might also have a look at:

Had a look, that extension looks to be the other way round IE to run tasks in the background not from the background.

My App runs in the background fine, as when I press the Arduino button the text to speech which fires before the called App works fine if My app is in the foreground or not, its just the called app only fires once My App is in the foreground.

EG
My App is in the background, I press the Arduino button, the text to speech is heard, no sign of the called App, bring My App to the foreground, the called App fires without having to call it again.

It's just waiting for My App to come to the foreground before it fires, weird or what...