AsyncTask toString()方法不起作用

时间:2015-02-20 20:33:17

标签: android amazon-web-services android-asynctask tostring amazon-simpledb

我正在尝试在AsyncTask类中的AWS-SimpleDB中创建一个域,但是每次执行它时App都会崩溃。它工作和崩溃的情况下的代码片段如下:

这有效:

   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);
}

但是,当我想将Date String添加到域名时,应用程序崩溃了:

    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对象?

1 个答案:

答案 0 :(得分:0)

我想问题是你发送“domain1Fri Feb 20 22:50:07 EET 2015”作为域名,不能有空格。