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 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 = new JSONObject(response);
boolean success = (1 == jsonResponse.getInt("success"));
if (success) {
Intent intent = getIntent();
intent.setClass(getBaseContext(), LoginActivity.class);
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;
}
}