Git Product home page Git Product logo

appactions-fitness-kotlin's Introduction

*:warning: Warning: Go to App Actions fitness sample or App Actions Widget sample for maintained sample.

⚠️ Warning: This App Actions fitness sample and App Actions Widget sample has migrated to App-Action directory in Android Github. This version will no longer be maintained.

This is a sample Fitness application that allows displaying workout information as well as starting and stopping a workout. By implementing App Actions, we allow the user to call upon our application to fulfill supported built-in intents (BIIs) in the fitness category.

Specifically, this sample supports the following BIIs:

  • actions.intent.START_EXERCISE: Open the sample app and start an exercise session.
  • actions.intent.STOP_EXERCISE: Open the sample app and stops the current exercise session.
  • actions.intent.GET_EXERCISE_OBSERVATION: Display a widget inside the Assistant with information on a particular exercise statistic.

alt-text

How to use this sample

Clone or download the project to your preferred location. Then, import and modify the project with the following steps:

  1. In Android Studio, select Open an existing Android Studio project from the initial screen, or go to File > Open.

  2. Change the applicationId in app/build.gradle to the applicationId of one of your draft or published apps in the Google Play Console.

    android {
        defaultConfig {
            // This ID uniquely identifies your app on the device and in Google Play
            applicationId "PUT_YOUR_APPLICATION_ID_HERE"
        }
    }
  3. Change the three (3) android:targetPackage in app/src/main/res/xml/shortcuts.xml to the applicationId in your app/build.gradle.

    <capability android:name="actions.intent.START_EXERCISE">
        <intent
            android:targetPackage="PUT_YOUR_APPLICATION_ID_HERE"
            >
        </intent>
    </capability>
    <capability android:name="actions.intent.STOP_EXERCISE">
        <intent
            android:targetPackage="PUT_YOUR_APPLICATION_ID_HERE"
            >
        </intent>
    </capability>
    <capability android:name="actions.intent.GET_EXERCISE_OBSERVATION">
        <intent
            android:targetPackage="PUT_YOUR_APPLICATION_ID_HERE"
            >
        </intent>
    </capability>
  4. In Android Studio, find the root directory of the sample.

  5. Select the build.gradle file.

  6. Follow the instructions presented by the IDE.

  7. Install Google Assistant plugin for Android Studio

Then, you can try the App Actions by following these steps:

  1. Build and run the sample on your physical test device (Run "app").
  2. Open the App Actions test tool (Tools > Google Assistant > App Actions Test Tool).
  3. Define an invocation name to use for invoking the App Actions (like "my test app"). This name is only for testing purposes, so it can be different from what you want to deploy to production later.
  4. Click Create Preview. Once your preview is created, the test tool window updates to display information about BIIs found in your shortcuts.xml file.

After you create a preview, you can then try using voice or written commands directly with Assistant on your test device.

If you run into any issues, check out the troubleshooting guide in our developer documentation.

Contribution guidelines

If you want to contribute to this project, be sure to review the contribution guidelines.

We use GitHub issues for tracking requests and bugs, please get support by posting your technical questions to Stack Overflow.

Report general issues with App Actions features or make suggestions for additional built-in intents through our public issue tracker.

References

License

Copyright 2019 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

appactions-fitness-kotlin's People

Contributors

marcelpinto avatar qchong avatar taycaldwell avatar xmasreturns avatar yoichiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appactions-fitness-kotlin's Issues

cant run the app after changing package name

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.devrel.android.a123987654z, PID: 24454
java.lang.RuntimeException: Unable to create application com.devrel.android.a123987654z.FitApp: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.PackageItemInfo.packageName' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6596)
at android.app.ActivityThread.access$1500(ActivityThread.java:230)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1911)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7551)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.PackageItemInfo.packageName' on a null object reference
at android.os.Parcel.createException(Parcel.java:2080)
at android.os.Parcel.readException(Parcel.java:2042)
at android.os.Parcel.readException(Parcel.java:1990)
at android.app.slice.ISliceManager$Stub$Proxy.grantSlicePermission(ISliceManager.java:540)
at android.app.slice.SliceManager.grantSlicePermission(SliceManager.java:450)
at androidx.slice.SliceManagerWrapper.grantSlicePermission(SliceManagerWrapper.java:69)
at com.devrel.android.a123987654z.FitApp.grantAssistantPermissions(FitApp.kt:50)
at com.devrel.android.a123987654z.FitApp.onCreate(FitApp.kt:35)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6591)
at android.app.ActivityThread.access$1500(ActivityThread.java:230) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1911) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:224) 
at android.app.ActivityThread.main(ActivityThread.java:7551) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995) 
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.slice.SliceManagerService.getProviderPkg(SliceManagerService.java:400)
at com.android.server.slice.SliceManagerService.enforceOwner(SliceManagerService.java:340)
at com.android.server.slice.SliceManagerService.grantSlicePermission(SliceManagerService.java:206)
at android.app.slice.ISliceManager$Stub.onTransact(ISliceManager.java:264)
at android.os.Binder.execTransactInternal(Binder.java:1021)

BII always return null in StatsWidget class

val bii = optionsBundle.getString(AppActionsWidgetExtension.EXTRA_APP_ACTIONS_BII)

When compile and run your code bii always return null in StatsWidget class

class StatsWidget(
    private val context: Context,
    private val appWidgetManager: AppWidgetManager,
    private val appWidgetId: Int,
    layout: Int,
) {
    private val views = RemoteViews(context.packageName, layout)
    private val repository = FitRepository.getInstance(context)
    private val hasBii: Boolean
    private val isFallbackIntent: Boolean
    private val aboutExerciseName: String
    private val exerciseType: FitActivity.Type

    init {
        val optionsBundle = appWidgetManager.getAppWidgetOptions(appWidgetId)
       // below line return null
      val bii = optionsBundle.getString(AppActionsWidgetExtension.EXTRA_APP_ACTIONS_BII)
        hasBii = !bii.isNullOrBlank()
        val params = optionsBundle.getBundle(AppActionsWidgetExtension.EXTRA_APP_ACTIONS_PARAMS)
        if (params != null) {
            isFallbackIntent = params.isEmpty
            if (isFallbackIntent) {
                aboutExerciseName = context.resources.getString(R.string.activity_unknown)
            } else {
                aboutExerciseName = params.get("aboutExerciseName") as String
            }
        } else {
            isFallbackIntent = false
            aboutExerciseName = context.resources.getString(R.string.activity_unknown)
        }
        exerciseType = FitActivity.Type.find(aboutExerciseName)
    }

    /**
     * Checks if widget should get requested or last exercise data and updates widget
     * accordingly
     */
    fun updateAppWidget() {
        if (hasBii && !isFallbackIntent) {
            observeAndUpdateRequestedExercise()
        } else observeAndUpdateLastExercise()
    }



    /**
     * Sets title, duration and distance data to widget
     */
    private fun setDataToWidget(
        exerciseType: String,
        distanceInKm: Float,
        durationInMin: Long
    ) {
        views.setTextViewText(
            R.id.activityType,
            context.getString(R.string.widget_activity_type, exerciseType)
        )
        views.setTextViewText(
            R.id.appwidgetDuration,
            context.getString(R.string.widqet_distance, distanceInKm)
        )
        views.setTextViewText(
            R.id.appwidgetDistance,
            context.getString(R.string.widget_duration, durationInMin)
        )
    }

    /**
     * Sets TTS to widget
     */
    private fun setTts(
        speechText: String,
        displayText: String,
    ) {
        val appActionsWidgetExtension: AppActionsWidgetExtension =
            AppActionsWidgetExtension.newBuilder(appWidgetManager)
                .setResponseSpeech(speechText)  // TTS to be played back to the user
                .setResponseText(displayText)  // Response text to be displayed in Assistant
                .build()

        // Update widget with TTS
        appActionsWidgetExtension.updateWidget(appWidgetId)
    }

    /**
     * Formats and sets activity data to Widget
     */
    private fun formatDataAndSetWidget(
        activityStat: FitActivity,
    ) {
        // formats date of activity
        val datePattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "EEEdMMMM")
        val formattedDate = DateFormat.format(datePattern, activityStat.date)


        // formats duration, distance and exercise name for widget
        val durationInMin = TimeUnit.MILLISECONDS.toMinutes(activityStat.durationMs)
        val distanceInKm = (activityStat.distanceMeters / 1000).toFloat()
        val activityExerciseType = activityStat.type.toString()
        val activityExerciseTypeFormatted = activityExerciseType.lowercase()


        setDataToWidget(activityExerciseType, distanceInKm, durationInMin)

        if (hasBii) {
            // formats speech and display text for Assistant
            // https://developers.google.com/assistant/app/widgets#tts
            val speechText = context.getString(
                R.string.widget_activity_speech,
                activityExerciseTypeFormatted,
                formattedDate,
                durationInMin,
                distanceInKm
            )
            val displayText = context.getString(
                R.string.widget_activity_text,
                activityExerciseTypeFormatted,
                formattedDate
            )
            setTts(speechText, displayText)
        }
    }

    /**
     * Formats and sets no activity data to Widget
     */
    private fun setNoActivityDataWidget() {
        val appwidgetTypeTitleText = context.getString((R.string.widget_no_data))
        val distanceInKm = 0F
        val durationInMin = 0L

        setDataToWidget(appwidgetTypeTitleText, distanceInKm, durationInMin)

        if (hasBii) {
            // formats speech and display text for Assistant
            // https://developers.google.com/assistant/app/widgets#library
            val speechText =
                context.getString(R.string.widget_no_activity_speech, aboutExerciseName)
            val displayText =
                context.getString(R.string.widget_no_activity_text)

            setTts(speechText, displayText)
        }
    }

    /**
     * Instruct the widget manager to update the widget
     */
    private fun updateWidget() {
        appWidgetManager.updateAppWidget(appWidgetId, views)
    }

    /**
     * Create and observe the last exerciseType activity LiveData.
     */
    private fun observeAndUpdateRequestedExercise() {
        val activityData = repository.getLastActivities(1, exerciseType)

        activityData.observeOnce { activitiesStat ->
            if (activitiesStat.isNotEmpty()) {
                formatDataAndSetWidget(activitiesStat[0])
                updateWidget()
            } else {
                setNoActivityDataWidget()
                updateWidget()
            }
        }
    }


    /**
     * Create and observe the last activity LiveData.
     */
    private fun observeAndUpdateLastExercise() {
        val activityData = repository.getLastActivities(1)

        activityData.observeOnce { activitiesStat ->
            if (activitiesStat.isNotEmpty()) {
                formatDataAndSetWidget(activitiesStat[0])
                updateWidget()
            } else {
                setNoActivityDataWidget()
                updateWidget()
            }
        }
    }

}

App Action not running with App Actions Test Tool

I'm trying to run the sample App Actions Fitness project but I can't get the AATT to execute any actions on my Samsung S8 device (or Emulator Pixel 3 with Android 10 & Google Assistant).
I've tried with AATT versions (3.1.1 & 3.1.2).

These are the steps i followed:

  1. Uploaded a signed draft application to my internal test track Google Play Store account without actions.xml in the AndroidManifest file.

  2. Installed the signed application with actions.xml in the manifest onto my device

  3. I'm running the latest version of the Assistant and the Google App

  4. I made sure the Assistant is properly setup

  5. I logged into my Google Play Store account, device/Assistant and Android Studio using the same account.

  6. Created a preview successfully using the AATT using Fit Actions as my invocation name and left the Locale blank.

  7. When i Run the AATT the Assistant is launched on the device but says, Sorry, I couldn't find it

I even tried to verify my setup using the suggested steps by @adamkoch on Stack Overflow and that didn't work.

I searched the adb logcat for the exact Intent that Assistant is trying to call but only found this:
I/ActivityManager: START u0 {act=android.intent.action.VIEW typ=null flg=0x10000000 cmp=ComponentInfo{com.google.android.googlequicksearchbox/com.google.android.apps.gsa.deeplink.DeeplinkActivityEntrypoint}} from uid 2000

Any thoughts and suggestions would be welcome.

Action not work via Assistant

action is running in the device via App Actions Test Tool but not working via voice or written commands in the Assistant.

below all steps are perfect in my case
The plugin loaded the actions preview at least one time.
The account in the device is the same as the one in Android Studio.
The device has access to an internet connection.
You are using the latest version of the Assistant or Google app.

can't run in google assistant

when i test on virtual device ,it's run normally.but when i test in my phone ,it can't runin google assistant ,and the assistant remind me "soory,can't find it".the process i make sure:
1.change the application id in my own.
2.upload the apk to google play console.
3.make sure the same account in google play console,Android Studio,google assistant in test device.
4.make sure the google is latest vision.
5.deleted actions preview and updated again from AATT.(App Actions Test Tool)
and then i looking at the logcat for the exact Intent that Assistant is trying to call. and i see the package name is not the package name i set .
how can i address this issue.

i also have a question.i want run this demo on Android TV,but when i use AATT and run ,it remind "no app to process".i wonder know if the apk can called by google assistant on TV

"Sorry, I couldn't find that"

Not working after following the given steps.
The steps mentioned are not enough and are not self-explainatory.
Difficult to find the exact issue.

App actions are working using App Action Testing Tools but not working in google assistant.

I have done the below steps:

Step 1) Create action.xml with Built-In Intent and defined in androidmanifest.xml

Step 2) Create a deep link through firebase dynamic link SDK

Step 3) Map the Deeplink with built-in Intent in android action.xml

Step 4) Create the application in Playstore

Step 5) Upload the signed APK in Playstore as save in draft

Step 6) Open the app action testing tool from the latest android studio after uploading the APK to the play store

Step 7) log in to the same google account in the play store, android studio, and android device

Step 8) Make sure the check the same Locale language (en-Us) in Android device and action testing tool.

It's working fine in APP Action Testing Tools But not working in Google Assistant.

I have deployed action in the google assistant console as well.

Google assistant opening conversation panel inside google assistant but not the opening application.

Can anyone get this example to work?

Hi
Help with this would be greatly appreciated.
I am using the latest google assistant on my android device (11.41.10.23.arm64)
I am following the documentation here: https://codelabs.developers.google.com/codelabs/appactions/#4
Last night I was successfully triggering this intent from the app actions test tool (version 3.5.1) but the voice commands where not working from google assistant when saying "Hey Google, start running in Fit Actions".

But this morning these intents aren't even working from the App Actions Test Tools despite not changing anything from last night. Assistant is saying "Sorry I couldn't find that".

Yesterday evening I went through all the troubleshooting tips I found on the official google docs https://developers.google.com/assistant/app/troubleshoot and in other github issues for this repo. E.g. Setting locale to en-US on my andorid device and the App Actions Test Tool but no luck.

If it helps the app package name is "com.dave.android.fitactions"
These are the commands I used to generate the APK:
./gradlew assembleRelease
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore my-release-key.keystore app/build/outputs/apk/release/app-release-unsigned.apk alias_name
I have submitted this APK to google to be internal tested. I am running the same APK on my device installed with "adb install app/build/outputs/apk/release/app-release-unsigned.apk" (ignore the file name; it is in fact a signed APK)
Does this whole thing work if and only if I download the APK through the internal testing play store once it has been approved? Or can it work with locally installed APKs?
I am lost with this
Many thanks

Widgets not working for GET INVOICE from google assistant.

Hi, I am trying to integrate the App widgets to the google code lab same sample app. The get Exercise observation works perfectly fine but when i am configuring actions.intent.GET_INVOICE, It works fine from test tool. But with voice inputs like "Get my Bill in " it says "App isn't installed". Any reasons for this ? Looking for fix.
Below is the code in shortcuts.xml for get voice :




 <capability android:name="actions.intent.GET_INVOICE">
   <app-widget
        android:identifier="GET_INVOICE"
        android:targetClass="com.devrel.android.fitactions.widgets.StatsWidgetProvider"
        android:targetPackage="com.ahk.assistantsample">
        <parameter
            android:name="invoice.forService.name"
            android:key="forServiceName"
            android:required="true">
        </parameter>
        <extra android:name="hasTts" android:value="true"/>
    </app-widget>

    <intent
        android:identifier="GET_INVOICE_FALLBACK"
        android:action="android.intent.action.VIEW"
        android:targetClass="com.devrel.android.fitactions.widgets.StatsWidgetProvider">
    </intent>
</capability>

Where to change BII?

Instead of calling

ok google, start running in fit actions

I would like to change/add own commands like

ok google, start recording in fit actions

or just

ok google, play in fit actions

How to change app name or calling name?

In this example the apps name is FitActions and I have to call "Ok Google. Start running in Fitactions". When I would apply thatr in my app, for sure the apps name will not be FitActions. Assuming I named my app Kawabanga so that I want to trigger by Ok Google. Start running in Kawabanga . What do I need to change?

I changed it, and the App Action Tool plugin tells me "Preview Creation Error Status Code: 400 Message: Precondition check failed."

  1. Loggen in on Android Studio with my Google developer Account
  2. Logged in on Google Assistant on my phone with same account
  3. Created google-services.json on Firebase Console for project kawabanga-12345 . Also in actions example replaced https://fitactions.firebaseapp.com/start{?exerciseType} by https://kawabanga-12345.firebaseapp.com/start{?exerciseType}

Is it really required to pusblish the appId in the Google Play Console? It is not mentioned in the steps earlier.
Whats wrong for the above error message and what am I missing?

Not able to open the app through google assistant

I have setup the project, uploaded the draft in play console, tried running action using app actions test tool. But Google assistant returns saying 'Sorry. Couldn't find that'. I have tried with the deep linking that is was already there in the project and also, i tried with custom scheme for deep linking. I am able to start the app using custom URI scheme from cmd. Account used in mobile device, play console and android studio are all same.
Also, please tell me how to change google account in app actions tool. I tried uninstalling and installing again but it directly takes to tool without asking me to login again.
Capture1
2019-05-25

Error: Targeted directory 'assets/a/a' is empty.

Hello, i am getting this error , help me thanks

Platform Windows

C:\Users\ALI FARZAN\Desktop\lemo>java -jar bundletool.jar build-apks --connected-device --bundle=lemogame_debug.aab --output=op.apks
INFO: The APKs will be signed with the debug keystore found at 'C:\Users\ALI FARZAN\.android\debug.keystore'.
[BT:0.10.2] Error: Targeted directory 'assets/a/a' is empty.
com.android.tools.build.bundletool.model.exceptions.ValidationException: Targeted directory 'assets/a/a' is empty.
        at com.android.tools.build.bundletool.model.exceptions.ValidationException$Builder.build(ValidationException.java:49)
        at com.android.tools.build.bundletool.model.exceptions.ValidationException$Builder.build(ValidationException.java:41)
        at com.android.tools.build.bundletool.validation.AssetsTargetingValidator.validateTargeting(AssetsTargetingValidator.java:54)
        at com.android.tools.build.bundletool.validation.AssetsTargetingValidator.lambda$validateModule$0(AssetsTargetingValidator.java:35)
        at java.util.Optional.ifPresent(Optional.java:159)
        at com.android.tools.build.bundletool.validation.AssetsTargetingValidator.validateModule(AssetsTargetingValidator.java:35)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:78)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleUsingSubValidator(ValidatorRunner.java:69)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundle$3(ValidatorRunner.java:58)
        at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundle(ValidatorRunner.java:58)
        at com.android.tools.build.bundletool.validation.AppBundleValidator.validate(AppBundleValidator.java:75)
        at com.android.tools.build.bundletool.commands.BuildApksManager.executeWithZip(BuildApksManager.java:131)
        at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:110)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:524)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:74)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:46)

I get an error when trying to upload the generated aab file in Google Play

When trying to upload the aab file to Google Play store I get the following error

"You uploaded an APK or Android App Bundle which specifies an actions schema document in its manifest, but action schemas are not yet allowed. If you are part of a beta program, you need to have your developer account whitelisted."

Can I whitelist my account myself or is this something you have to do somehow?

App widget is showing only 1 time

Hi i have integrated app widget with google assistant . widget is showing only 1 time next time onwards google assistant return white screen
Screenshot_1659450724

Unable to create preview in app actions test tool

We are trying to test app actions using App Actions test tool.
We are getting following error on click of create preview -

Preview Creation Error Status Code: 400 Message: Precondition check failed. - Please ensure that your Google account has authorization in Play Console to modify the app with package name 'com.devrel.android.fitactions'.

Not able to install Google Assistant

One requirement to run this example application is to install https://play.google.com/store/apps/details?id=com.google.android.apps.googleassistant&hl=en
However, I can't seem to install this on my (rooted) Galaxy S3 running Android 7.1.2 Any ideas?

And one more clarification: with this example, I will be able to talk to the Google Assistant on my phone and it will start this app, right?
Will I also be able to talk to the Google Assistant inside my Google Home (mini) to start the app on my phone?

Unresolved reference: START_EXERCISE

I see this error : Unresolved reference: START_EXERCISE

Please find the code below for FitMainActivity.xml and shortcuts.xml. Am I missing anything here?

Screenshot 2023-03-29 at 2 18 28 PM

shortcuts.xml





<shortcut
    android:shortcutId="running"
    android:shortcutShortLabel="@string/activity_running">
    <capability-binding android:key="actions.intent.START_EXERCISE">
        <parameter-binding
            android:key="exercise.name"
            android:value="@array/runningSynonyms"/>
    </capability-binding>
</shortcut>

<shortcut
    android:shortcutId="walking"
    android:shortcutShortLabel="@string/activity_walking">
    <capability-binding android:key="actions.intent.START_EXERCISE">
        <parameter-binding
            android:key="exercise.name"
            android:value="@array/walkingSynonyms"/>
    </capability-binding>
</shortcut>

<shortcut
    android:shortcutId="cycling"
    android:shortcutShortLabel="@string/activity_cycling">
    <capability-binding android:key="actions.intent.START_EXERCISE">
        <parameter-binding
            android:key="exercise.name"
            android:value="@array/cyclingSynonyms"/>
    </capability-binding>
</shortcut>

Android Codelab "Extend an Android app to Google Assistant with App Actions" has not been updated to reflect changes to git repository

The code at https://codelabs.developers.google.com/codelabs/appactions/#2 does not compile as is, and the "Warning" and modified directions at https://github.com/actions-on-google/appactions-fitness-kotlin are extremely unclear.

For example,
"How to use this sample
Clone or download the project to your preferred location. Then, import and modify the project with the following steps:

In Android Studio, select Open an existing Android Studio project from the initial screen, or go to File > Open."

Okay, at this point, from which repository was the code for "this" project cloned?

Anyway, even if the modified directions on github are clarified, isn't the whole idea of Codelabs to provide simple projects such that if the instructions are followed exactly, the project will work without modification and troubleshooting?

App Action works when testing with plugin but not when called via voice with Google Assistant

Hey again!

My app action works when tested with the app action plugin in Android Studio. But I am not able to get it working via voice in google assistant. I have made a draft and uploaded onto the google play store, made sure my android studio account, my account that is connected to the assistant and the account on my developer account are the same ones. Is there something obvious that I am missing?

Thanks!

Examples not working - inconsistency

I am trying this Google Assistant example here, quite for a while - in vain. There are different ways described, but none of them work properly.

  1. Here it is described to generate a google-services.json and to put that into the app/ folder. I tried that twice as described, I was logged in with that very same Google Account on Android Studio, on my physical device and its Google Assistant account, etc.
  2. Here we have a step by step tutorial by Google Codelabs and I tried everything until step 4, where I install the Action Test plugin. However, clicking the run in that plugin opens a google Assistant in my device telling me "Sorry I could not find anything" regarding that voice command. Also until step 4, I couldnt find anything regarding a google-services.json? Instead I had to upload an internal test release version into my Playstore, which in turn was not mentioned in 1.

java.lang.SecurityException: Caller must own content://.....MySliceProvider

I am trying to implement assistant into my own app, I am getting

java.lang.SecurityException: Caller must own content://at.oeamtc.android.oeamtclib.MySliceProvider

This is the part where it is crashing, on SliceManager.getInstance(context)
.grantSlicePermission(assistantPackage, sliceProviderUri);

`private void grantAssistantPermissions() {
Context context = getApplicationContext();
Uri sliceProviderUri =
new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(OeamtcSliceProvider.SLICE_AUTHORITY)
.build();

    String assistantPackage = getAssistantPackage(context);
    if (assistantPackage == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        SliceManager.getInstance(context)
                .grantSlicePermission(assistantPackage, sliceProviderUri);
    }
}

private String getAssistantPackage(Context context) {
    PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> resolveInfoList = packageManager.queryIntentServices(
            new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0);
    if (resolveInfoList.isEmpty()) {
        return null;
    }
    return resolveInfoList.get(0).serviceInfo.packageName;
}`

Running sample via voice

Hey!

I have clone this sample onto my local machine. I connected the sample to firebase to get rid of the missing google-services.json. I then open up google assistant and say " Start my run using Fitness Action Sample” but the app doesn't start, instead I get a google search page. Do I need to upload this apk as a draft for me to be able to trigger via voice?

Thanks!

Action - "Sorry, I couldn't find that"

When the phone is locked, nothing is working even from app action tool and getting this error "Sorry, I couldn't find that".
is there any BII or conversation action from Action SDK available that works with locked phone ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.