0

我试图使用 php 文件在我的应用程序中实现忘记密码功能,但遇到了一些错误。我向用户询问他们的电子邮件,然后我将它们存储在参数中,以便我的 php 文件可以获取电子邮件并将其发送给他们。

下面是我的代码:

btnPasswordSubmit.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // new ForgotPassword().execute();
            String recoveryPassword = txtRecoveryPassword.getText()
                    .toString();

            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("email", recoveryPassword));
            // getting JSON Object
            // Note that create event URL accepts POST method
            JSONObject json = jsonParser.makeHttpRequest(
                    forgotPassword_url, "POST", params);

            // check log cat for response
            Log.d("Create Response", json.toString());

            // check for success tag
            try {
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {
                    // successfully email sent
                    Intent intent = new Intent(getApplicationContext(),
                            ForgotPasswordSuccessActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    // failed to create event
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });

这是我的日志:

08-22 16:32:58.904: E/JSON Parser(271): Error parsing data org.json.JSONException: End of input at character 0 of 
08-22 16:32:58.924: E/AndroidRuntime(271): FATAL EXCEPTION: main
08-22 16:32:58.924: E/AndroidRuntime(271): java.lang.NullPointerException
08-22 16:32:58.924: E/AndroidRuntime(271):  at com.stts.sparetimetradingsystem.ForgotPasswordActivity$1.onClick(ForgotPasswordActivity.java:57)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.view.View.performClick(View.java:2408)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.view.View$PerformClick.run(View.java:8816)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.os.Handler.handleCallback(Handler.java:587)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.os.Looper.loop(Looper.java:123)
08-22 16:32:58.924: E/AndroidRuntime(271):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 16:32:58.924: E/AndroidRuntime(271):  at java.lang.reflect.Method.invokeNative(Native Method)
08-22 16:32:58.924: E/AndroidRuntime(271):  at java.lang.reflect.Method.invoke(Method.java:521)
08-22 16:32:58.924: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 16:32:58.924: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 16:32:58.924: E/AndroidRuntime(271):  at dalvik.system.NativeStart.main(Native Method)
08-22 16:39:22.534: E/JSON Parser(350): Error parsing data org.json.JSONException: End of input at character 0 of 
08-22 16:39:22.564: E/AndroidRuntime(350): FATAL EXCEPTION: main
08-22 16:39:22.564: E/AndroidRuntime(350): java.lang.NullPointerException
08-22 16:39:22.564: E/AndroidRuntime(350):  at com.stts.sparetimetradingsystem.ForgotPasswordActivity$1.onClick(ForgotPasswordActivity.java:57)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.view.View.performClick(View.java:2408)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.view.View$PerformClick.run(View.java:8816)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.os.Handler.handleCallback(Handler.java:587)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.os.Looper.loop(Looper.java:123)
08-22 16:39:22.564: E/AndroidRuntime(350):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 16:39:22.564: E/AndroidRuntime(350):  at java.lang.reflect.Method.invokeNative(Native Method)
08-22 16:39:22.564: E/AndroidRuntime(350):  at java.lang.reflect.Method.invoke(Method.java:521)
08-22 16:39:22.564: E/AndroidRuntime(350):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 16:39:22.564: E/AndroidRuntime(350):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 16:39:22.564: E/AndroidRuntime(350):  at dalvik.system.NativeStart.main(Native Method)
08-22 16:43:45.264: E/JSON Parser(378): Error parsing data org.json.JSONException: End of input at character 0 of 
08-22 16:43:45.294: E/AndroidRuntime(378): FATAL EXCEPTION: main
08-22 16:43:45.294: E/AndroidRuntime(378): java.lang.NullPointerException
08-22 16:43:45.294: E/AndroidRuntime(378):  at com.stts.sparetimetradingsystem.ForgotPasswordActivity$ForgotPassword$1.run(ForgotPasswordActivity.java:85)
08-22 16:43:45.294: E/AndroidRuntime(378):  at android.os.Handler.handleCallback(Handler.java:587)
08-22 16:43:45.294: E/AndroidRuntime(378):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-22 16:43:45.294: E/AndroidRuntime(378):  at android.os.Looper.loop (Looper.java:123)
08-22 16:43:45.294: E/AndroidRuntime(378):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 16:43:45.294: E/AndroidRuntime(378):  at java.lang.reflect.Method.invokeNative(Native Method)
08-22 16:43:45.294: E/AndroidRuntime(378):  at java.lang.reflect.Method.invoke(Method.java:521)
08-22 16:43:45.294: E/AndroidRuntime(378):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 16:43:45.294: E/AndroidRuntime(378):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 16:43:45.294: E/AndroidRuntime(378):  at dalvik.system.NativeStart.main(Native Method)
08-22 16:46:22.954: E/JSON Parser(409): Error parsing data org.json.JSONException: End of input at character 0 of 
08-22 16:46:22.976: E/AndroidRuntime(409): FATAL EXCEPTION: main
08-22 16:46:22.976: E/AndroidRuntime(409): java.lang.NullPointerException
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.stts.sparetimetradingsystem.ForgotPasswordActivity$1.onClick(ForgotPasswordActivity.java:62)

08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.View.performClick(View.java:2408)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.View.onKeyUp(View.java:4121)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.widget.TextView.onKeyUp(TextView.java:4431)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.KeyEvent.dispatch(KeyEvent.java:1061)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.View.dispatchKeyEvent(View.java:3740)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1667)
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.app.Activity.dispatchKeyEvent(Activity.java:2063)
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.os.Looper.loop(Looper.java:123)
08-22 16:46:22.976: E/AndroidRuntime(409):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 16:46:22.976: E/AndroidRuntime(409):  at java.lang.reflect.Method.invokeNative(Native Method)
08-22 16:46:22.976: E/AndroidRuntime(409):  at java.lang.reflect.Method.invoke(Method.java:521)
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 16:46:22.976: E/AndroidRuntime(409):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 16:46:22.976: E/AndroidRuntime(409):  at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

0

您是否使用空字符串对此进行测试?基于来自 logcat 的这一行:

08-22 16:32:58.904: E/JSON Parser(271): Error parsing data org.json.JSONException: End of input at character 0 of 

看起来它正在尝试解析空字符串并失败。

于 2012-08-22T17:23:04.803 回答