I am using SQL for my database. I have cross-verified all names of the variables and parameters they are correct. I have cross-verified my PHP script using postman snd I am getting correct output but when moving on to send data from the mobile I am getting com.android.volley.authfailureError.
Following is my android code...
package com.example.researchprojectv2;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private EditText emp_ID, password;
private Button btn_submit;
private TextView txt;
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
emp_ID = findViewById(R.id.editTextNumber);
password = findViewById(R.id.editTextTextPassword);
btn_submit = findViewById(R.id.button);
txt = findViewById(R.id.login);
progressDialog = new ProgressDialog(this);
txt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, Login.class);
startActivity(intent);
}
});
btn_submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
registerUser();
progressDialog.show();
progressDialog.setTitle("Please while registering");
}
});
}
private void registerUser() {
final String empID = emp_ID.getText().toString().trim();
final String passWD = password.getText().toString().trim();
progressDialog.setMessage("Registering User....");
StringRequest stringRequest = new StringRequest(Request.Method.POST,
Constants.URL_REGISTER,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
progressDialog.hide();
try {
JSONObject jsonObject = new JSONObject(response);
Toast.makeText(getApplicationContext(), jsonObject.getString(
"message"), Toast.LENGTH_LONG).show();
Intent intent = new Intent(MainActivity.this, hhh.class);
startActivity(intent);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.toString(), Toast.LENGTH_LONG).show();
progressDialog.hide();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("emp_id", empID);
params.put("password", passWD);
return params;
}
};
//200000 is the time in milliseconds adn is equal to 200 sec
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
200000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestHandler.getInstance(this).addToRequestQueue(stringRequest);
}
}
log report (android studio)
07/05 01:00:34: Launching 'app' on Xiaomi Redmi Note 7 Pro.
$ adb shell am start -n "com.example.researchprojectv2/com.example.researchprojectv2.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 19184 on device 'xiaomi-redmi_note_7_pro-5a14c494'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/searchprojectv: Late-enabling -Xcheck:jni
W/searchprojectv: miui_dex2oat: DeoptimizeBootImage: patch entry points of methods in boot image to interpreter bridge
W/searchprojectv: miui_dex2oat: OatFile: /data/app/com.example.researchprojectv2-R6-g_SKERFwg6QfVgTpG1A==/oat/arm64/base.odex Compiler-Filter = speed-profile
I/Perf: Connecting to perf service.
W/searchprojectv: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/searchprojectv: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
I/Adreno: QUALCOMM build : 89f10b9, I3d0e3ac366
Build Date : 12/25/18
OpenGL ES Shader Compiler Version: EV031.25.14.03
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
Build Config : S P 6.0.9 AArch64
I/Adreno: PFP: 0x016ee177, ME: 0x00000000
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
E/LB: fail to open file: No such file or directory
I/AssistStructure: Flattened final assist data: 3016 bytes, containing 1 windows, 10 views
I/DpmTcmClient: RegisterTcmMonitor from: $Proxy0
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
E/Volley: [6558] BasicNetwork.performRequest: Unexpected response code 403 for http://192.168.43.26/android/v1/Registeruser.php
E/Volley: [6558] BasicNetwork.performRequest: Unexpected response code 403 for http://192.168.43.26/android/v1/Registeruser.php
I/Toast: Show toast from OpPackageName:com.example.researchprojectv2, PackageName:com.example.researchprojectv2
I/searchprojectv: ProcessProfilingInfo new_methods=153 is saved saved_to_disk=1 resolve_classes_delay=8000
I Google it more and more resolved it by my self, by adding port number after the IP in the URL.