-1

I've created an app that should use as registeration page for any user .(The details that the user need to provide is : Name,UserName,Password, and age). I think that everything is ok , so i cannot understand why when i press the send button that should communicate with my domain, the app is crashing . Maybe something wrong with the code?

Here is the JAVA CODE:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    final EditText etAge= (EditText) findViewById(R.id.etAge);
    final EditText etName= (EditText) findViewById(R.id.etName);
    final EditText etUsername= (EditText) findViewById(R.id.etUsername);
    final EditText etPassword= (EditText) findViewById(R.id.etPassword);
    final Button bRegister = (Button)findViewById(R.id.bRegister);

    bRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String name=etName.getText().toString();
            final String username=etUsername.getText().toString();
            final String password=etPassword.getText().toString();
            final int age=Integer.parseInt(etAge.getText().toString());

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

                @Override
                public void onResponse(String response){
                    try {
                        JSONObject jsonResponse=new JSONObject(response);
                        boolean success=jsonResponse.getBoolean("success");

                        if(success){
                            Intent intent=new Intent(RegisterActivity.this, LoginActivity.class);
                            RegisterActivity.this.startActivity(intent);
                        }
                        else{
                            AlertDialog.Builder builder= new AlertDialog.Builder(RegisterActivity.this);
                            builder.setMessage("ההרשמה נכשלה .")
                           .setNegativeButton("נסה שוב",null)
                                    .setIcon(R.drawable.erroricon)
                                    .create()
                                    .show();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            };
         RegisterRequest registerRequest= new RegisterRequest(name,username,age,password,responseListener);
            RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
            queue.add(registerRequest);


        }
    });



}
}     

And here is the crash details(Which i cannot understand anything from this)

07-29 19:13:03.139 2881-2881/com.commandofox.loginrequest E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.commandofox.loginrequest, PID: 2881
                                                                            java.lang.NumberFormatException: For input string: ""
                                                                                at java.lang.Integer.parseInt(Integer.java:620)
                                                                                at java.lang.Integer.parseInt(Integer.java:643)
                                                                                at com.commandofox.loginrequest.RegisterActivity$1.onClick(RegisterActivity.java:37)
                                                                                at android.view.View.performClick(View.java:6219)
                                                                                at android.view.View$PerformClick.run(View.java:24482)
                                                                                at android.os.Handler.handleCallback(Handler.java:769)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                at android.os.Looper.loop(Looper.java:164)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6540)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

EDIT 3
Here's what the app is saying as error when I'm trying to complete the reqisteration request:

 07-29 19:32:27.948 9882-10087/com.commandofox.loginrequest E/Volley: [246] BasicNetwork.performRequest: Unexpected response code 404 for http:/nittiest-jurisdicti.000webhostapp.com/register.php
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Toad32
  • 19
  • 7

1 Answers1

1

Check your manifest, may be you did not add the INTERNET permission there.

Edit 1

After you posted logs, it becomes clearer - you tried to convert empty string ("" is a empty string of etAge editText) to int. It causes exception.

Valentun
  • 1,661
  • 12
  • 23
  • I did. I've attached the Crash details. Please look into it. – Toad32 Jul 29 '17 at 19:17
  • @YonatanAlkobi see edit 1 – Valentun Jul 29 '17 at 19:21
  • Watch at the following video: I learned from this video the coding for this stage and it looks like that Although my code is exactly like him, for some reason the app is working fine for him. – Toad32 Jul 29 '17 at 19:29
  • The link : https://www.youtube.com/watch?v=T7Z4GVFaT4A&list=LL_CFQ2DfMKj2hzud0a5dvPQ&index=2&t=84s – Toad32 Jul 29 '17 at 19:29
  • @YonatanAlkobi when you test your app do you fill the age edit text? – Valentun Jul 29 '17 at 19:30
  • yes, i do ........ – Toad32 Jul 29 '17 at 19:32
  • Please look at edit 3 in my post – Toad32 Jul 29 '17 at 19:35
  • @YonatanAlkobi, 404 is a not found (page) status. Check your URL please – Valentun Jul 29 '17 at 19:37
  • 24207-24269/com.commandofox.loginrequest D/NetworkSecurityConfig: No Network Security Config specified, using platform default /? W/audio_hw_generic: Not supplying enough data to HAL, expected position 4715691 , only wrote 4563360 07-30 08:14:15.800 1524-1598/? D/ConnectivityService: NetworkAgentInfo [MOBILE (LTE) - 100] validation failed – Toad32 Jul 30 '17 at 08:16
  • @YonatanAlkobi it is a debug message ("D/") not error – Valentun Jul 30 '17 at 08:57