javascript - Json Object cannot be cast to Float using parse.com cloud function Android -
I'm following the tutorial to get cloud data on Android. The Java script code is given below:
Parse.Cloud.define ("average star", function (request, response) {var query = new parse.Query ("review"); query. EqualTo ("film", request.params.movie); query.find ({success: work (result) for {var sum = 0; (var i = 0; i & lt; result; tall; ++ i) {Sum + = result [i] .get ("stars");} response.success (sum / results.length);}, error: function () {response.error ("movie lookup failed")}}) }});
The code on Android side is given below:
@OrrideCreative on Public Zero (bundled saved instainstate) {super.onCreate (savedInstanceState); Get a view from // listview_main.xml setContentView (R.layout.listview_main); Hashmap & lt; String, Object & gt; Parameters = new Hashmop & lt; String, Object & gt; (); Params.put ("film", "matrix"); ParseCloud.callFunctionInBackground ("average star", parameter, new function callback & lt; float & gt; () {public zero (float ratings, parsection e) {if (e == null) {// rating 4.5}}} ); / / Execute RemoteDataTask AsyncTask New RemoteDataTask (). Executed (); }
I have successfully deployed the code from the Pars Console to the cloud. But I am getting the error: java.lang.ClassCastException: org.json.JSONObject put $ 1 on java.lang Can not be done. Float
Please acknowledge that where I am wrong I fully followed the tutorial Thank you in advance.
You can call function callback & lt; Float & gt; () Are not overridden;
Please replace the pars cloud function like this:
Parsecloud. Calfunction in background ("average star", parameter, new function callback & lt; float & Gt; () {@ Override public zero (float rating, parsexation e) {if (e == empty) {// ratings 4}}});
Comments
Post a Comment