我使用的是AWS Android SDK示例应用程序UserPreferenceDemo中的一些代码。我让示例应用程序工作,以便它能够创建一个新的DynamoDB表。然而,当我尝试在我的应用程序中实现相同的代码时,我在AmazonClientManager类中得到了日志消息"Credentials were“,并且我的应用程序崩溃了。
下面是我用来创建表的代码。
final Button submit = (Button) findViewById(R.id.bSubmitComplete)
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i(TAG, "submitBttn clicked.");
new DynamoDBManagerTask()
.execute(DynamoDBManagerType.CREATE_TABLE);
}
});下面是记录消息的代码。
public Response validateCredentials() {
Response ableToGetToken = Response.SUCCESSFUL;
if (AmazonSharedPreferencesWrapper
.areCredentialsExpired(this.sharedPreferences)) {
synchronized (this) {
if (AmazonSharedPreferencesWrapper
.areCredentialsExpired(this.sharedPreferences)) {
Log.i(LOG_TAG, "Credentials were expired.");
AmazonTVMClient tvm = new AmazonTVMClient( this.sharedPreferences, PropertyLoader.getInstance().getTokenVendingMachineURL(), PropertyLoader.getInstance().useSSL() );
ableToGetToken = tvm.anonymousRegister();
if (ableToGetToken.requestWasSuccessful()) {
ableToGetToken = tvm.getToken();
if (ableToGetToken.requestWasSuccessful()) {
Log.i(LOG_TAG, "Creating New Credentials.");
initClients();
}
}
}
}
} else if (ddb == null) {
synchronized (this) {
if (ddb == null) {
Log.i(LOG_TAG, "Creating New Credentials.");
initClients();
}
}
}
return ableToGetToken;
}发布于 2013-06-28 09:42:08
简单的解决方法,愚蠢的问题,但我已经花了一段时间研究这个问题了。
已卸载并重新安装应用程序。现在它可以工作了
https://stackoverflow.com/questions/17354588
复制相似问题