在开发与Android应用程序集成的物联网设备时,我遇到了这个问题。
我希望实现的是与我的应用程序交谈,例如,“Alexa,炊具内的温度是多少?”。要获取此信息,我有一个Android应用程序通过蓝牙和应用程序连接到智能电磁炉,而不是从电磁炉读取温度信息。
现在我如何在我的Android应用程序中获取查询,如何将我的响应返回为“当前炊具温度为100摄氏度”。而alexa可以为我表达它。
这是我到目前为止所做的。
accessToken
requestContext = RequestContext.create(this)
requestContext.registerListener(object : AuthorizeListener() {
override fun onSuccess(authorizeResult: AuthorizeResult) {
accessToken = authorizeResult.accessToken
Timber.d("Access Token: %s", accessToken)
}
override fun onCancel(auth: AuthCancellation?) {
Timber.e(auth?.description)
}
override fun onError(error: AuthError) {
Timber.e(error, error.localizedMessage)
}
})
signInBtn.setOnClickListener {
AuthorizationManager.authorize(
AuthorizeRequest.Builder(requestContext)
.addScopes(ProfileScope.profile(), ProfileScope.postalCode())
.build()
)
}
这是清单的相关声明
<activity android:name="com.amazon.identity.auth.device.workflow.WorkflowActivity"
android:theme="@android:style/Theme.NoDisplay"
android:allowTaskReparenting="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- android:host must use the full package name found in Manifest General Attributes -->
<data android:host="${applicationId}" android:scheme="amzn"/>
</intent-filter>
</activity>
我一直在关注this文档。
我需要做什么才能在我的应用程序中获取查询以处理并返回结果?还是可以的?
您需要创建一个智能家居技能来实现它,您需要前进的方式