如何在cloudboost

时间:2016-04-05 10:16:48

标签: cloudboost

我试图在用户登录时使用下面的代码将所有角色分配给用户。

public class roles extends AsyncTask <String,Void,Void>{

       @Override
       protected Void doInBackground(String... params) {

           final CloudUser user = new CloudUser();
           final CloudRole role = new CloudRole("MCA");

           user.setUserName(params[0]);
           user.setPassword(params[1]);


               try {
                   user.logIn(new CloudUserCallback() {
                       @Override
                       public void done(CloudUser cloudUser, CloudException e) throws CloudException {
                           if (cloudUser != null) {
                               System.out.println("login Successful");
                               System.out.println(cloudUser.getUserName());
                               cloudUser.isInRole(role);
                           }
                           if (e != null) {
                               System.out.println("In logn exception");
                               e.printStackTrace();
                           }


                       }
                   });
               } catch (CloudException e) {
                   e.printStackTrace();
               }


               return null;
       }
    }

我收到以下错误:

致命异常:AsyncTask#1                                                                     处理:com.rakesh_kr.image,PID:31256                                                                     java.lang.RuntimeException:执行doInBackground()时发生错误                                                                         在android.os.AsyncTask $ 3.done(AsyncTask.java:300)                                                                         在java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)                                                                         at java.util.concurrent.FutureTask.setException(FutureTask.java:222)                                                                         在java.util.concurrent.FutureTask.run(FutureTask.java:242)                                                                         在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)                                                                         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)                                                                         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)                                                                         在java.lang.Thread.run(Thread.java:818)                                                                      引起:java.lang.ClassCastException:io.cloudboost.json.JSONArray无法强制转换为java.util.ArrayList                                                                         at io.cloudboost.CloudUser.isInRole(CloudUser.java:335)                                                                         在com.rakesh_kr.image.MainActivity $ roles $ 1.done(MainActivity.java:174)                                                                         at io.cloudboost.CloudUser.logIn(CloudUser.java:219)                                                                         在com.rakesh_kr.image.MainActivity $ roles.doInBackground(MainActivity.java:168)                                                                         在com.rakesh_kr.image.MainActivity $ roles.doInBackground(MainActivity.java:155)                                                                         在android.os.AsyncTask $ 2.call(AsyncTask.java:288)                                                                         在java.util.concurrent.FutureTask.run(FutureTask.java:237)                                                                         在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)                                                                         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)                                                                         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)                                                                         在java.lang.Thread.run(Thread.java:818)

1 个答案:

答案 0 :(得分:0)

这是JavaSDK之前版本的CloudBoost v1.0.7中出现的错误,已修复,请从github克隆最新来源或获取最新jar(1.0.7)从现在起几个小时内就可以在maven上找到它。