1

我正在尝试从内置意图测试actions.intent.OPEN_APP_FEATURE,但是在启动内置意图的应用程序操作测试工具时出现错误,在我收到该错误之前几个小时工作正常。

以下是我尝试启动 App Actions 时的错误

kotlin.UninitializedPropertyAccessException: lateinit property onlineDevicesStateSubject has not been initialized
    at com.google.assistant.plugin.PluginSingletons$Companion.getOnlineDevicesStateSubject(PluginSingletons.kt:9)
    at com.google.assistant.plugin.ui.ActionSelectionDialog.createPreviewTestingFrame(ActionSelectionDialog.kt:353)
    at com.google.assistant.plugin.ui.ActionSelectionDialog.createCenterPanel(ActionSelectionDialog.kt:136)
    at com.intellij.openapi.ui.DialogWrapper.init(DialogWrapper.java:1331)
    at com.google.assistant.plugin.ui.ActionSelectionDialog.<init>(ActionSelectionDialog.kt:106)
    at com.google.assistant.plugin.actions.ActionsTestAction.actionPerformed(ActionsTestAction.kt:21)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:281)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:310)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:286)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:299)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:110)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:110)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:514)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:544)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6652)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
    at java.desktop/java.awt.Component.processEvent(Component.java:6417)
    at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2784)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:976)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:911)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:840)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:828)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:507)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

以下是我在操作文件中使用的代码

<?xml version ="1.0" encoding ="utf-8"?><!--  Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<actions>
    <action intentName="actions.intent.OPEN_APP_FEATURE">
        <fulfillment urlTemplate="https://url.page.link/open{?featureName}">
            <parameter-mapping
                intentParameter="feature"
                urlParameter="featureName" />
        </fulfillment>

        <parameter name="feature">
            <entity-set-reference entitySetId="FeatureEntitySet" />
        </parameter>
    </action>

    <entity-set entitySetId="FeatureEntitySet">
        <entity
            name="Profile"
            identifier="profile" />
        <entity
            name="Setting"
            identifier="setting" />
        <entity
            name="Gang"
            identifier="gang" />
        <entity
            name="Blind"
            identifier="blind" />
        <entity
            name="Light"
            identifier="light" />
    </entity-set>
</actions>

对于清单,我在应用程序标签中添加以下内容

<meta-data
    android:name="com.google.android.actions"
    android:resource="@xml/actions" />

对于活动,我添加了以下意图

intent-filter
    android:autoVerify="true"
    tools:targetApi="m">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="url.page.link"
        android:scheme="https" />
</intent-filter>

在活动中,我添加以下内容以针对意图采取行动

intent.handleIntent()

private fun Intent.handleIntent() {
    when (action) {
        Intent.ACTION_VIEW -> {
            handleDeepLink(data)
        }
    }
}

private fun handleDeepLink(data: Uri?) {
    if (data?.path == "/open") {
        featureType = data.getQueryParameter("featureName").orEmpty()
        Toast.makeText(applicationContext, "Working $featureType", Toast.LENGTH_LONG).show()
    }
}
4

0 回答 0