gpt4 book ai didi

amazon-web-services - 调用Amplify.DataStore.save()时,应用程序卡住

转载 作者:行者123 更新时间:2023-12-02 13:41:15 25 4
gpt4 key购买 nike

我正在使用Kotlin和AWS Amplify制作一个简单的移动应用程序。我将从显示我的设置开始。我的schema.graphql:

type OfferGQL @model {
id: ID!
name: String!
description: String!
address: String!
price: Float!
}
我的AWS插件的设置如下:
    Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.addPlugin(AWSS3StoragePlugin())
Amplify.addPlugin(AWSDataStorePlugin())
Amplify.configure(applicationContext)
这是我尝试将数据保存到DataStore的方法:
// Create a new offer object
val newOffer = OfferGQL.builder()
.name(textFieldOfferName.text.toString())
.description(textFieldOfferDescription.text.toString())
.address(textFieldOfferAddress.text.toString())
.price(textFieldOfferPrice.text.toString().toFloat())
.build()

// Put it in the DataStore
Amplify.DataStore.save(newOffer,
{result ->
runOnUiThread{Toast.makeText(this,"Offer added successfully", Toast.LENGTH_LONG).show()}
},
{error ->
println(error.message)
println(error.localizedMessage)
println(error.cause)
println(error.recoverySuggestion)
})
问题是,当我调用Amplify.DataStore.save()时,整个应用程序将冻结。我按照文档进行了配置,所以现在我真的不知道为什么会发生这种情况。

最佳答案

在手机上完全重新安装该应用程序后,该功能终于可以使用了。

关于amazon-web-services - 调用Amplify.DataStore.save()时,应用程序卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63300301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com