如何解决价值

时间:2014-12-10 05:44:33

标签: android json

我正在尝试将数据发送到服务器并且我的应用程序崩溃并显示此错误可以任何人帮助我这个........

 Error Parsing dataorg.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
12-10 10:54:46.630: W/dalvikvm(870): threadid=11: thread exiting with uncaught exception (group=0x409961f8)
 FATAL EXCEPTION: AsyncTask #1
 java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:278)
    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
 Caused by: java.lang.NullPointerException
    at info.androidhive.slidingmenu.RegistrationForm$AttemptLogin.doInBackground(RegistrationForm.java:435)
    at info.androidhive.slidingmenu.RegistrationForm$AttemptLogin.doInBackground(RegistrationForm.java:1)
    at android.os.AsyncTask$2.call(AsyncTask.java:264)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    ... 5 more
 Activity info.androidhive.slidingmenu.RegistrationForm has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41888e70 that was originally added here
 android.view.WindowLeaked: Activity info.androidhive.slidingmenu.RegistrationForm has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41888e70 that was originally added here
    at android.view.ViewRootImpl.<init>(ViewRootImpl.java:343)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:245)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
    at android.view.Window$LocalWindowManager.addView(Window.java:537)
    at android.app.Dialog.show(Dialog.java:274)
    at info.androidhive.slidingmenu.RegistrationForm$AttemptLogin.onPreExecute(RegistrationForm.java:375)
    at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
    at android.os.AsyncTask.execute(AsyncTask.java:511)
    at info.androidhive.slidingmenu.RegistrationForm.onClick(RegistrationForm.java:291)
    at android.view.View.performClick(View.java:3480)
    at android.view.View$PerformClick.run(View.java:13983)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4340)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)

在此处查看我的代码https://stackoverflow.com/questions/27393384/how-to-send-data-from-android-to-php-server-using-json?noredirect=1#comment43233981_27393384

1 个答案:

答案 0 :(得分:1)

这部分logcat:

  

错误解析dataorg.json.JSONException:类型为java.lang.String的值 <br 不能

所有人都喜欢点击中断标记<br />。问题是您没有收到任何JSON数据。

您需要调查原因,可能的原因:

  1. 网络问题
  2. 许可问题
  3. 响应无效

  4. class AttemptLogin extends AsyncTask<String, String, String> {
        boolean failure = false;
    
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            ....
        }
    
        @SuppressWarnings("unused")
        @Override
        protected String doInBackground(String...args) {
            .....
            try {
                //Building Parameters
                .....
    
                json = jsonParser.makeHttpRequest (
                LOGIN_URL, "POST", params);
                Log.d("Request attempt", json.toString());
                JSONObject jobj = new JSONObject(json.toString());
                return jobj;
    
            }catch (JSONException e) {
                e.printStackTrace();
            }
            return null;
        }
    
        protected void onPostExecute(JSONObject jobj) {
            pDialog.dismiss();
            try {
                if(jobj.getString(TAG_SUCCESS)){
                    final String msg = jobj.getString("msg");
                    Toast.makeText(
                          getApplicationContext(),msg, Toast.LENGTH_LONG)
                         .show();
                }else{
                    System.out.println("FAIL !!");
                }
    
            }catch (JSONException e) {
                e.printStackTrace();
            }
    
    
        }
    }