stack on integrating parse cloud code in android app -


here main.js:

parse.cloud.define("averagestats", function(request, response) {   var rating = parse.object.extend("statobject");   var query = new parse.query("rating");   query.equalto("location", request.params.location);   query.find({     success: function(results) {       var sum = 0;       (var = 0; < results.length; ++i) {         sum += results[i].get("rating");       }       response.success(sum / results.length);     },     error: function() {       response.error("location lookup failed");     }   }); }); 

in mainactivity.java:

location = (edittext) findviewbyid(r.id.fldlocation); string loc = location.gettext().tostring(); hashmap<string, object> params = new hashmap<string, object>(); params.put("location", loc); parsecloud.callfunctioninbackground("averagestats", params, new functioncallback <float> () {     @override     public void done(float curentrating, com.parse.parseexception e) {         if (e==null){             //return curentrating;             rating = curentrating;         }         else{             rating = 0.0f;         }     } }); stats = (edittext) findviewbyid(r.id.fldstats); stats.settext(string.valueof(rating)); 

program crashing with: caused by: java.lang.nullpointerexception: attempt invoke virtual method 'java.io.file com.parse.parseplugins.getparsedir()' on null object reference

the pointer goes line: parsecloud.callfunctioninbackground("averagestats", params, new functioncallback <float> ()

please understand what's wrong.

solved !!!

just added

    parse.enablelocaldatastore(this);     parse.initialize(this,xxxxxx,xxxxxxxxxx); 

before calling cloud method


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -