Make parsing of Google Maps URIs more flexible

When opening a location in certain apps (like WhatsApp) the value of q
in the called URI is something like "loc:xx.xxxxxxx,x.xxxxxxx (Du) ".
Until now extract() expects "xx.xxxxxxx,x.xxxxxxx" as input and cannot
parse URIs like the one above.

Solve this problem by cutting off unnessessary peaces of the URI.
This commit is contained in:
Michael Laß 2013-07-20 22:11:38 +02:00
parent 996fd29a4a
commit c9987e46bb

View file

@ -201,11 +201,15 @@ public class GeoIntentActivity extends OsmandListActivity {
*/
private MyService extract(Uri data) {
if ("http".equalsIgnoreCase(data.getScheme()) && "maps.google.com".equals(data.getHost())) {
String q = data.getQueryParameter("q");
String q = data.getQueryParameter("q").split(" ")[0];
if (q.indexOf(',') != -1) {
int i = q.indexOf(',');
String lat = q.substring(0, i);
String lon = q.substring(i + 1);
if (lat.indexOf(":") != -1) {
i = lat.indexOf(":");
lat = lat.substring(i + 1);
}
try {
double llat = Double.parseDouble(lat.trim());
double llon = Double.parseDouble(lon.trim());