匿名注册成功后,无法用AVUser.getCurrentUser(XXX.class)转换
class XXX extends AVUser {}
AVAnonymousUtils.logIn(new LogInCallback<AVUser>() {
@Override
public void done(AVUser arg0, AVException arg1) {
if(arg1==null){
AVUser.getCurrentUser(XXX.class)
}
}
});
java.lang.ClassCastException: com.avos.avoscloud.AVUser cannot be cast to XXX
at com.xxx.MainActivity$2.done(MainActivity.java:89)
at com.avos.avoscloud.LogInCallback.internalDone0(LogInCallback.java:42)
at com.avos.avoscloud.LogInCallback.internalDone0(LogInCallback.java:32)
at com.avos.avoscloud.AVCallback.internalDone(AVCallback.java:18)
at com.avos.avoscloud.AVAnonymousUtils$1.onSuccess(AVAnonymousUtils.java:66)
...
这是什么原因? 是不是匿名注册不支持扩展AVUser?
匿名登录之后,SDK为你创建的currentUser是AVUser类型的对象,而不是你这里的
XX extends AVUser
。你可以使用下面这个方法,将currentUser改为子类对象。