java - Redirect to google maps language -
i have code snippet redirects user google maps current position , coordinates end location.
creating redirect button
directions.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string message = getapplicationcontext().getstring(r.string.directions_info); new alertdialog.builder(detailsactivity.this) .settitle(getapplicationcontext().getstring(r.string.open_google)) .setmessage(string.format(message, cityobject.getname()+"?")) .seticon(r.drawable.ic_google_maps) .setnegativebutton(android.r.string.cancel, null) // dismisses default .setpositivebutton(android.r.string.ok, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { //string test = "https://www.google.com/maps?saddr=my+location&daddr=%f,%f(%s)&travelmode=walking"; string test = getstring(r.string.directions_url); coordinates end = cityobject.getcoordinates(); string name = cityobject.getname().replace(' ', '+'); string urlstring = string.format(test, end.getlatitude(), end.getlongitude(), name); intent intent = new intent(intent.action_view, uri.parse(urlstring)); startactivity(intent); } }) .create() .show(); } });
directions string:
<string formatted="false" name="directions_url">https://www.google.com/maps?saddr=my+location&daddr=%f,%f(%s)&travelmode=walking</string>
the thing is, works when have app set on english, when change locale swedish, google maps says can't find "my location". have exact same string english , swedish don't understand problem is.
maybe has google , formatting of string depending on language?
Comments
Post a Comment