com.parse.ParseObject无法转换为 [英] com.parse.ParseObject cannot be cast to
问题描述
我正在开发具有解析平台的应用程序.要获取数据,我正在调用ParseCloud.callFunctionInBackground
函数.
I am developing application which having Parse Platform. To fetch data I am calling ParseCloud.callFunctionInBackground
function.
我已经将解析及其子类注册到Application类中,如下所示:
I have registered the Parse and its sub class into the Application class like below :
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());
}
}
我在下面的模型类中扩展了ParseObject:
I have below model class which extends 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 :
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无法转换为 com.example.ParseMessage
java.lang.ClassCastException: com.parse.ParseObject cannot be cast to com.example.ParseMessage
我已经在Google和Stackoverflow上搜索了很多产品,但没有得到任何解决方案.谁能帮我解决这个问题,因为我已经花了很多时间了.下面是我从Parse得到的响应:
I already searched lots of thins from Google and Stackoverflow, but I did not get any solutions of it. Can anyone help me into this as I already spend a lot of time on this. Below response which I am getting from Parse :
推荐答案
您提供的信息不是很具体,但是从调试器屏幕上看,您似乎正在尝试将ParsePhoto
转换为ParseMessage
. ParsePhoto
是ParseObject
的子类,我相信这是造成此问题的原因.
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
is subclass of ParseObject
, and I believe this is causing the issue.
这篇关于com.parse.ParseObject无法转换为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!