[英]Pushing dynamic shortcut to google assistant on android
我正在尝试将动态快捷方式推送到 Google 助理,如下所述: Google 的文档。
代码运行良好,如果我在启动器中点击并按住我的图标,我会得到快捷方式,但是如果我在助手设置中转到快捷方式,我的应用程序甚至没有列出...
这是创建快捷方式的代码:
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("Test", "Test");
ShortcutInfoCompat.Builder scBuilder = new ShortcutInfoCompat.Builder(this, "Locate")
.setShortLabel("Locate item")
.setLongLabel("Locate specific item")
.addCapabilityBinding("custom.actions.intent.LOCATE")
.setIntent(intent);
if (!ShortcutManagerCompat.pushDynamicShortcut(this, scBuilder.build()))
{
Log.d("INTENT", "Failed...");
}
pushDynamicShortcut 不返回 false。
还有我的shortcut.xml:
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<capability
android:name="custom.actions.intent.LOCATE"
app:queryPatterns="@array/LocateQueries">
<intent android:action="android.intent.action.VIEW">
</intent>
</capability>
<shortcut
android:shortcutId="Locate"
android:shortcutShortLabel="@string/actionLocate">
<intent
android:targetClass="com.XXX.MainActivity"
android:targetPackage="com.XXX" />
<capability-binding android:key="custom.actions.intent.LOCATE">
</capability-binding>
</shortcut>
</shortcuts>
该应用程序目前已发布在商店中,我正在更新...
问题是测试手机实际上与用于发布应用程序的帐户不在同一个帐户上。 删除了所有帐户,添加了一个并且它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.