Federico Desia
Newbie
Java:
public String SolicitudServidor(final Activity activity, final String Type, final String Name, final String Surname, final String Username, final String Password){
String URL, Response;
if(Type.equals("Register")){
URL="http://web-androidapp.000webhostapp.com/androidapp/registerUser.php?name="+Name.replaceAll(" ", "%20")+"&surname="+Surname.replaceAll(" ", "%20")+"&username="+Username+"&password="+Password;
}else if(Type.equals("Check")){
URL="http://web-androidapp.000webhostapp.com/androidapp/CheckUser.php?username="+Username;
}
StringRequest stringRequest=new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
JSONObject jsonObject=new JSONObject(response);
Response=jsonObject.getString("Ok");
}catch (JSONException e){
e.printStackTrace();
MostrarPopUp("Error", activity);
}
}
},
new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error){
MostrarPopUp("Error", activity);
}
});
RequestQueue requestQueue= Volley.newRequestQueue(activity);
requestQueue.add(stringRequest);
return Response;
}
I'm getting an error when using the URL and Response variables. Cannot resolve symbol 'URL' or 'Response'. If I define the variable as final String it appears: Variable 'URL' or 'Response' might not have been initialized.