I am sending a request to the volley web library on android containing several Arabic characters in the URL, but in the php file I got question marks instead of my Arabic letters (??????), I tried the solutions that people spoke on the network but they all try to read data from the Internet, as UTF-8 does not send data as UTF-8.
Here is my code:
String url = "http://mywebsite.com/file.php?parameter=سلام"
JsonObjectRequest request = new JsonObjectRequest(Method.GET, url, null, new Listener<JSONObject>(){
@Override
public void onResponse(JSONObject response)
{
try
{
if(response.has("result") && response.getBoolean("result"))
{
prefs.edit().putBoolean(Launcher.REGISTERED_KEY, true).apply();
Intent intent = new Intent(Subscribe.this, Home.class);
Toast.makeText(Subscribe.this, R.string.register_success_message, Toast.LENGTH_LONG).show();
startActivity(intent);
Subscribe.this.finish();
}
else
{
msgBox.setText(R.string.subscribtion_error);
}
}
catch(Exception e)
{
msgBox.setText(R.string.subscribtion_error);
e.printStackTrace();
}
}
}, new ErrorListener(){
@Override
public void onErrorResponse(VolleyError error)
{
msgBox.setText(R.string.subscribtion_error);
Log.e("", error.toString());
}
}){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
};
source
share