我正试图在AsyncTask类内的AWS SimpleDB中创建一个域,但每次执行时应用程序都会崩溃。它工作和崩溃的代码片段如下:
这项工作:
protected Void doInBackground(Param... params) {
private static final String APP_DOMAIN = "Domain1";
AWSCredentials credentials = new BasicAWSCredentials(Constants.ACCESS_KEY_ID, Constants.SECRET_KEY);
this.sdbClient = new AmazonSimpleDBClient(credentials);
CreateDomainRequest cdr = new CreateDomainRequest(APP_DOMAIN);
this.sdbClient.createDomain(cdr);
}
但是,当我想将日期字符串添加到域名时,应用程序崩溃了:
protected Void doInBackground(Param... params) {
static Date dt = new Date();
private static final String APP_DOMAIN = "Domain1"+dt.toString();
AWSCredentials credentials = new BasicAWSCredentials(Constants.ACCESS_KEY_ID, Constants.SECRET_KEY);
this.sdbClient = new AmazonSimpleDBClient(credentials);
CreateDomainRequest cdr = new CreateDomainRequest(APP_DOMAIN);
this.sdbClient.createDomain(cdr);
}
我在这里做错了什么?是AsyncTask不能将Date对象传递给它吗?
我想问题是你正在发送"domain1Fri Feb 20 22:50:07 EET 2015"作为域名,不可能有空白。