[英]com.parse.ParseObject cannot be cast to
I am developing application which having Parse Platform .我正在开发具有Parse Platform 的应用程序。 To fetch data I am calling
ParseCloud.callFunctionInBackground
function.为了获取数据,我正在调用
ParseCloud.callFunctionInBackground
函数。
I have registered the Parse and its sub class into the Application class like below :我已将 Parse 及其子类注册到 Application 类中,如下所示:
public class App extends Application {
@Override
public void onCreate(){
super.onCreate();
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.networkInterceptors().add(httpLoggingInterceptor);
ParseObject.registerSubclass(ParseMessage.class);
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("KEY")
.server("URL")
.build());
}
}
I have below model class which extends ParseObject :我有以下扩展 ParseObject 的模型类:
@ParseClassName("ParseMessage")
public class ParseMessage extends ParseObject {
// Ensure that your subclass has a public default constructor
public ParseMessage() {
super();
}
public ParsePhoto getPhotos() {
return (ParsePhoto) getParseObject("photos");
}
public void setPhotos(ParsePhoto value) {
put("photos", value);
}
public String getCaption() {
return getString("caption");
}
public void setCaption(String value) {
put("caption", value);
}
}
When I calling this below method from my Fragment :当我从 Fragment 调用以下方法时:
HashMap<String, Object> params = new HashMap<String, Object>();
ParseCloud.callFunctionInBackground("MY_METHOD", params, new FunctionCallback<ArrayList<ParseMessage>>() {
public void done(ArrayList<ParseMessage> mapObject, ParseException e) {
if (e == null) {
ParseMessage object = mapObject.get(i);
}
} else {
}
}
});
But I am getting below exception :但我得到以下异常:
java.lang.ClassCastException: com.parse.ParseObject cannot be cast to com.example.ParseMessage
java.lang.ClassCastException: com.parse.ParseObject 不能转换为 com.example.ParseMessage
I already searched lots of thins from Google and Stackoverflow, but I did not get any solutions of it.我已经从谷歌和 Stackoverflow 上搜索了很多东西,但我没有得到任何解决方案。 Can anyone help me into this as I already spend a lot of time on this.
任何人都可以帮助我解决这个问题,因为我已经花了很多时间在这上面。 Below response which I am getting from Parse :
下面是我从 Parse 得到的回复:
The info you have provided is not very concrete, but from the debugger screen, it looks like you are trying to convert ParsePhoto
into ParseMessage
.您提供的信息不是很具体,但从调试器屏幕来看,您似乎正在尝试将
ParsePhoto
转换为ParseMessage
。 ParsePhoto
is subclass of ParseObject
, and I believe this is causing the issue. ParsePhoto
是子类ParseObject
,我相信这是造成问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.