2
I develope android application ,one of my concept is pass user rating of an android  application

all are required paramter to pass ratelogin asynchronus ,
 When i run my  Android application i got the Exception during the debugging  my application ,i gave my exception  below,please any one give the solution for this problem..thanks in advance.

**My exception is** 

>org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject

MyActiviy: //where the paramater passed to RateLogin asynchronus task

new rateLogin().execute(userid, Strbookid,userrating, Deviceid);

//Asychronus task for ratelogin 

class rateLogin extends AsyncTask<String, String, String> {

    String userid = "";
    String Strbookid = "";
    String userRating="";
    String Deviceid = "";
   @Override
    protected String doInBackground(String... strings) {
        userid = strings[0];
        Strbookid = strings[1];
        userRating=strings[2];
        Deviceid = strings[3];

/*Rate login : XMl Http Post
Here login user id,Book id, application rate for user given, mobile device id */ HttpClient httpClient = new DefaultHttpClient(); // Creating HTTP Post

        HttpPost httpPost = null;

        List<NameValuePair> nameValuePair = null;
            httpPost = new HttpPost(
                Rateurl);
        // Building post parameters and  key and value pair
        nameValuePair = new ArrayList<NameValuePair>(4);
        nameValuePair.add(new BasicNameValuePair("userid", userid));
        nameValuePair.add(new BasicNameValuePair("bookid", Strbookid));
        nameValuePair.add(new BasicNameValuePair("userrating", userRating));
        nameValuePair.add(new BasicNameValuePair("deviceid", Deviceid));
        // Url Encoding the POST parameters and  writing error to Log
            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
        // Making HTTP Request to user rating value
            HttpResponse response = httpClient.execute(httpPost);
try
{
//this line only got Exception
            String strRet = HttpHelper.request(response);
   // writing exception to log of Rate login
}catch(Exception e)

}

            Log.d(strRet, "strstrRet");

            JSONObject jsonObjRecv=null;

                    jsonObjRecv  = new JSONObject(strRet);
                String result = jsonObjRecv.getString("status");
                String message = jsonObjRecv.getString("info");
                if (result.equals("Success")) {
                    showalert(message);
} 
           else {
                    showalert(message);
                }
        return null;
     }
 }
1
  • any one give the solution,,thanks.. Commented Aug 7, 2015 at 10:39

1 Answer 1

2

I think you are getting wrong response from server. If you debug app you find that your response is something like this

I have faced same problem. So its server error not android.....

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.