简体   繁体   English

com.parse.ParseObject 不能转换为

[英]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 得到的回复:

来自 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.

相关问题 java.lang.ClassCastException: java.util.ArrayList 不能转换为 com.parse.ParseObject - java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.parse.ParseObject NoClassDefFoundError: com.parse.ParseObject$1 - NoClassDefFoundError: com.parse.ParseObject$1 无法将类别转换为ParseObject - Class cannot be cast to ParseObject android.widget.ImageView无法转换为com.parse.ParseImageView - android.widget.ImageView cannot be cast to com.parse.ParseImageView NumberFormat:parse()vs parseObject() - NumberFormat: parse() vs parseObject() Android,Mandrill和Parse.com:Java ClassCastException:HashMap无法转换为类 - Android, Mandrill and Parse.com: Java ClassCastException: HashMap cannot be cast to a class Parse.com Android SDK:下载后,ParseObject上的EstimatedData和serverData立即不同 - Parse.com Android SDK: estimatedData and serverData on ParseObject differ immediately after download java.lang.ClassCastException:org.json.JSONObject $ 1无法转换为Task(我的自定义ParseObject) - java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to Task (my custom ParseObject) getParseFile(string key)从带有扩展ParseObject类的Parse.com返回null - getParseFile(string key) returning null from Parse.com with extended ParseObject class (Parse-SDK) 如何访问列表<ParseObject>来自另一个 ParseObject? - (Parse-SDK) How to access List<ParseObject> from another ParseObject?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM