Click here to Skip to main content
13,344,765 members (61,090 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
i have developed a simple user login system with registration.
i have referred few websites for developed that?
but i can't identify the issue properly?

this is the error i've got?
after i compiled it and when i type daa in textboxes,
it will show below error?

W/IInputConnectionWrapper: finishComposingText on inactive InputConnection

these are other errors i'm getting?

W/System.err: org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
W/System.err: at com.hemas.virtualfoods.RegisterActivity$1$1.onResponse(RegisterActivity.java:45)
com.hemas.virtualfoods W/System.err: at com.hemas.virtualfoods.RegisterActivity$1$1.onResponse(RegisterActivity.java:39)
com.hemas.virtualfoods W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
com.hemas.virtualfoods W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
com.hemas.virtualfoods W/System.err: at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
com.hemas.virtualfoods W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
com.hemas.virtualfoods W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
com.hemas.virtualfoods W/System.err: at android.os.Looper.loop(Looper.java:154)
com.hemas.virtualfoods W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6077)
com.hemas.virtualfoods W/System.err: at java.lang.reflect.Method.invoke(Native Method)
com.hemas.virtualfoods W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
com.hemas.virtualfoods W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

What I have tried:

RegisterActivity.java

package com.hemas.virtualfoods;

import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;

import org.json.JSONException;
import org.json.JSONObject;

public class RegisterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        final EditText regName = (EditText)findViewById(R.id.regName);
        final EditText regPassword = (EditText)findViewById(R.id.regPassword);
        //final EditText regConfirmPass = (EditText) findViewById(R.id.regConfirmPass);
        final EditText regPhone = (EditText)findViewById(R.id.regPhone);
        final EditText regEmail = (EditText)findViewById(R.id.regEmail);

        final Button regButton = (Button)findViewById(R.id.regButton);

        regButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                final String username = regName.getText().toString();
                final String password = regPassword.getText().toString();
                final String phoneno = regPhone.getText().toString();
                final String email = regEmail.getText().toString();

                Response.Listener<String> responseListener = new Response.Listener<String>() {
                    @Override

                    public void onResponse(String response) {
                        try {
                          //  JSONObject jsonResponse = (JSONObject) new JSONTokener(response).nextValue();
                           JSONObject jsonResponse = new JSONObject(response);
                            boolean success = (1 == jsonResponse.getInt("success"));

                            if (success) {
                                Intent intent = getIntent();
                                intent.setClass(getBaseContext(), LoginActivity.class);
                                startActivity(intent);

                                //Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                                //RegisterActivity.this.startActivity(intent);
                            } else {
                                AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
                                builder.setMessage("Register Failed")
                                        .setNegativeButton("Retry", null)
                                        .create()
                                        .show();
                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }



                    }
                };

                RegisterRequest registerRequest = new RegisterRequest(username, password, phoneno, email, responseListener);
                RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
                queue.add(registerRequest);
            }
        });
}
}


RegisterRequest.java

package com.hemas.virtualfoods;

import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;

import java.util.HashMap;
import java.util.Map;

public class RegisterRequest extends StringRequest {

private static final String REGISTER_REQUEST_URL = "https://wary-stars.000webhostapp.com/Register.php";
private Map<String, String> params;

public RegisterRequest(String username, String password, String phoneno, String email, Response.Listener<String> listener){
        super(Method.POST, REGISTER_REQUEST_URL, listener, null);
        params = new HashMap<>();
        params.put("username", username);
        params.put("password", password);
        params.put("phoneno", phoneno);
        params.put("email", email);
        }

public Map<String, String> getParams() {
        return params;
        }
        }
Posted 18-Aug-17 8:43am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.180111.1 | Last Updated 18 Aug 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100