I'm just wondering if I have an EditText that I turn the contents into a string, say
String queryStr = new String(searchText.getText().toString());
How can I escape the special characters from this string so that I can put it in the HttpGet method? Thank!
Use java.net.URLEncoder :
java.net.URLEncoder.encode(queryStr, "UTF-8");
Try:
TextUtils.htmlEncode(queryStr);
I think you need to do what you want.
- :
import android.net.Uri; ... private String getParams(String queryStr) { Uri.Builder builder = new Uri.Builder(); builder.appendQueryParameter("your_parameter_key", queryStr); return builder.toString(); }
URL.
String() .
String queryStr = searchText.getText().toString();