Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Guys am getting this errors in android studio my app automatically closed and can't be connect with mysql

HTML
01/01 11:42:06: Launching app
    No apk changes detected since last installation, skipping installation of C:\Users\SAJID\Desktop\ComplainProtectionCell3\ComplainProtectionCell\app\build\outputs\apk\app-debug.apk
    $ adb shell am force-stop com.example.sajid.complainprotectioncell
    $ adb shell am start -n "com.example.sajid.complainprotectioncell/com.example.sajid.complainprotectioncell.Register" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    Client not ready yet..Waiting for process to come online
    Waiting for process to come online
    Connected to process 5976 on device emulator-5554
    I/art: Ignoring second debugger -- accepting and dropping
    Application terminated.


What I have tried:

C#
package com.example.sajid.complainprotectioncell;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.HashMap;


public class Register extends AppCompatActivity {
//    public static final String URL = "https://interactivebookfyp.000webhostapp.com/user/signUp.php";
//    AsyncHttpClient client = new AsyncHttpClient();

    Button register, log_in;
    EditText U_Name, Email, Password,Cnic,Phone ;
    String F_Name_Holder, L_Name_Holder, EmailHolder, PasswordHolder;
    String finalResult ;
    String HttpURL = "https://localhost:83/panel/UserRegistration.php";
    Boolean CheckEditText ;
    ProgressDialog progressDialog;
    HashMap<String,String> hashMap = new HashMap<>();
    HttpParse httpParse = new HttpParse();


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

        //Assign Id'S
        U_Name = (EditText)findViewById(R.id.input_name);
        Email = (EditText)findViewById(R.id.input_email);
        Password = (EditText)findViewById(R.id.input_password);
        Cnic = (EditText)findViewById(R.id.input_cnic);
        Phone= (EditText)findViewById(R.id.input_phone);
        register = (Button)findViewById(R.id.BtnGo);

        log_in = (Button)findViewById(R.id.login);

        //Adding Click Listener on button.
        register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                // Checking whether EditText is Empty or Not
                CheckEditTextIsEmptyOrNot();

                if(CheckEditText){

                    // If EditText is not empty and CheckEditText = True then this block will execute.

                    UserRegisterFunction(F_Name_Holder,L_Name_Holder, EmailHolder, PasswordHolder);

                }
                else {

                    // If EditText is empty then this block will execute .
                    Toast.makeText(Register.this, "Please fill all form fields.", Toast.LENGTH_LONG).show();

                }


            }
        });

        log_in.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(Register.this,Login.class);
                startActivity(intent);

            }
        });

    }

    public void CheckEditTextIsEmptyOrNot(){

        F_Name_Holder = U_Name.getText().toString();
        L_Name_Holder = Email.getText().toString();
        EmailHolder = Email.getText().toString();
        PasswordHolder = Password.getText().toString();


        if(TextUtils.isEmpty(F_Name_Holder) || TextUtils.isEmpty(L_Name_Holder) || TextUtils.isEmpty(EmailHolder) || TextUtils.isEmpty(PasswordHolder))
        {

            CheckEditText = false;

        }
        else {

            CheckEditText = true ;
        }
}

    public void UserRegisterFunction(final String F_Name, final String L_Name, final String email, final String password){

        class UserRegisterFunctionClass extends AsyncTask<String,Void,String> {

            @Override
            protected void onPreExecute() {
                super.onPreExecute();

                progressDialog = ProgressDialog.show(Register.this,"Loading Data",null,true,true);
            }

            @Override
            protected void onPostExecute(String httpResponseMsg) {

                super.onPostExecute(httpResponseMsg);

                progressDialog.dismiss();

                Toast.makeText(Register.this,httpResponseMsg.toString(), Toast.LENGTH_LONG).show();

            }

            @Override
            protected String doInBackground(String... params) {

                hashMap.put("U_Name",params[0]);

                hashMap.put("Email",params[1]);

                hashMap.put("Password",params[2]);

                hashMap.put("Cnic",params[3]);

                hashMap.put("Phone",params[3]);

                finalResult = httpParse.postRequest(hashMap, HttpURL);

                return finalResult;
            }
        }

        UserRegisterFunctionClass userRegisterFunctionClass = new UserRegisterFunctionClass();

        userRegisterFunctionClass.execute(F_Name,L_Name,email,password);
    }

}
Posted
Updated 8-Jan-18 20:04pm
v2
Comments
David Crow 2-Jan-18 9:10am    
Have you tried any of:

* Close and re-open AS.
* Clean the project.
* Remove the app from the device and re-deploy.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900