Reputation: 35
My question is all about how to shorten url in android ?
The url I want shortened:
Upvotes: 0
Views: 731
Reputation: 35
Thanks for all your support finally I got what I need,
I have encoded all the lat and long using ,
/**
* Encodes a sequence of LatLngs into an encoded path string.
*/
public String encode(final List<LatLng> path) {
long lastLat = 0;
long lastLng = 0;
final StringBuffer result = new StringBuffer();
for (final LatLng point : path) {
long lat = Math.round(point.latitude * 1e5);
long lng = Math.round(point.longitude * 1e5);
long dLat = lat - lastLat;
long dLng = lng - lastLng;
encode(dLat, result);
encode(dLng, result);
lastLat = lat;
lastLng = lng;
}
return result.toString();
}
private void encode(long v, StringBuffer result) {
v = v < 0 ? ~(v << 1) : v << 1;
while (v >= 0x20) {
result.append(Character.toChars((int) ((0x20 | (v & 0x1f)) + 63)));
v >>= 5;
}
result.append(Character.toChars((int) (v + 63)));
}
then, I used Google API for encoding again the full URL.
Upvotes: 2