How to pass special characters to url in volleyball call in android
String description="60% off";
String url_offerAdd=UrlString.url_string+"/offer_Add.php?email="+email+"&desc="+description;
url_offerAdd.replace(" ","%20");
## Heading ##StringRequest stringRequest=new StringRequest(Request.Method.GET, url_offerAdd, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.v("response",response);
Toast.makeText(getBaseContext(),"Offer is submitted succcessfully",Toast.LENGTH_LONG).show();
desc.setText("");
tvToDate.setText("");
desc.setFocusable(false);
tvFromDate.setText("");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.v("response1",error.getMessage());
}
});
MySingleton.getInstance(getApplicationContext()).addToRequestque(stringRequest);
Since I accepted the description at 60%, so whenever I call the php webservice, the% character is not passed to the url as none of the special charecters get through.
+3
source to share
3 answers
you can try this method, working great for me.
String urll ="http://www.google.com/methodname?Userid="+user_id;
String url = Uri.parse(urll)
.buildUpon()
.appendQueryParameter("Title", title)
.appendQueryParameter("Desc", description)
.appendQueryParameter("embededvideo", embededvideo)
.appendQueryParameter("location", location)
.appendQueryParameter("perferances", perferances)
.appendQueryParameter("taguser", taguser)
.appendQueryParameter("userpostimage", images)
.build().toString();
0
source to share