Android Square Picasso Not Load Persian Character Image Url
I want to create web application by square picasso, but if image url contains persian characters (ا،ب،ج،ی، ...) Picasso not load image. This url not working: Picass
Solution 1:
You need to URI encode the URL.
See the docs
Uri.encode(url);
Or, if specifying certain allowed characters the following works:
privatestaticfinalStringALLOWED_URI_CHARS="@#&=*+-_.,:!?()/~'%";
StringurlEncoded= Uri.encode(path, ALLOWED_URI_CHARS);
Solution 2:
You need to encode your Url
.
So try this
URIUtil.encodeQuery(myUrl).
or also this one : http://developer.android.com/reference/java/net/URLEncoder.html
URLEncoder.encode(myUrl, "UTF-8");
Also there is an issue here
Solution 3:
just use from this function
publicstaticStringencodUrl(String url){
String[] splitUrl = url.split("/");
String imageName = splitUrl[splitUrl.length-1];//get name of fileString mainUrl = url.replaceAll(imageName , "");//get url without file name bacause dont need to encodereturn (mainUrl + Uri.encode(imageName));
}
Post a Comment for "Android Square Picasso Not Load Persian Character Image Url"