有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java组织。json。JSONException:输入结束于:虚拟InputConnection绑定的字符0处,

为什么我会犯这样的错误?我已经为我的问题寻找了可能的解决办法,但我找不到

代码如下:

//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem) {

    class HttpWebCallFunction extends AsyncTask<String,Void,String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            pDialog = ProgressDialog.show(ShowSingleRecordActivity.this,"Loading Data",null,true,true);
        }

        @Override
        protected void onPostExecute(String httpResponseMsg) {

            super.onPostExecute(httpResponseMsg);

            pDialog.dismiss();

            //Storing Complete JSon Object into String Variable.
            FinalJSonObject = httpResponseMsg ;

            //Parsing the Stored JSOn String to GetHttpResponse Method.
            new GetHttpResponse(ShowSingleRecordActivity.this).execute();

        }

        @Override
        protected String doInBackground(String... params) {

            ResultHash.put("StudentID",params[0]);

            ParseResult = httpParse.postRequest(ResultHash, HttpURL);

            return ParseResult;
        }
    }

    HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();

    httpWebCallFunction.execute(PreviousListViewClickedItem);
}


// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>
{
    public Context context;

    public GetHttpResponse(Context context)
    {
        this.context = context;
    }

    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... arg0)
    {
        try
        {
            if(FinalJSonObject != null)
            {
                JSONArray jsonArray = null;

                try {
                    jsonArray = new JSONArray(FinalJSonObject);

                    JSONObject jsonObject;

                    for(int i=0; i<jsonArray.length(); i++)
                    {
                        jsonObject = jsonArray.getJSONObject(i);


                        NameHolder = jsonObject.getString("name").toString() ;
                        SurnameHolder = jsonObject.getString("surname").toString() ;
                        AddressHolder = jsonObject.getString("address").toString() ;
                        ContactnoHolder = jsonObject.getString("contactno").toString() ;
                        UsernameHolder = jsonObject.getString("username").toString() ;
                        PasswordHolder = jsonObject.getString("password").toString() ;

                    }
                }
                catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        catch (Exception e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result)
    {

        // Setting Student Name, Phone Number, Class into TextView after done all process .
        NAME.setText(NameHolder);
        SURNAME.setText(SurnameHolder);
        ADDRESS.setText(AddressHolder);
        CONTACTNO.setText(ContactnoHolder);
        USERNAME.setText(UsernameHolder);
        PASSWORD.setText(PasswordHolder);
    }
}

共 (0) 个答案