获得使用谷歌地图API的Andr​​oid应用程序驾驶指令 [英] Getting driving instructions in android application using Google Directions API

查看:147
本文介绍了获得使用谷歌地图API的Andr​​oid应用程序驾驶指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个Android应用程序在那里我应该显示行车路线给用户。
我使用谷歌API方向本。
这包括使请求他们的URL和获取JSON的结果。
现在的问题是:行车路线是TAG /名称里面 - HTML指令。
在这里,我得到的方向,但它嵌入了如UNI code字符。

I have this android app where I am supposed to show the driving directions to the users. I am using Google Directions API for this. This involves making request to their url and getting the JSON in result. Now, the problem is : the driving directions are inside the TAG/Name - "html-instructions". Here I get the directions, but it's embedded with unicode characters for eg.

html_instructions:就拿1 \\ u003cb \\ u003eleft \\ u003c / B \\ u003e朝\\ u003cb \\ u003eBannerugatta路\\ u003c / B \\ u003e

"html_instructions": "Take the 1st \u003cb\u003eleft\u003c/b\u003e toward \u003cb\u003eBannerugatta Rd\u003c/b\u003e"

我该如何摆脱这些UNI code值,并得到明文出来。

How do I get rid of these unicode values and get the plain text out of it.

请帮忙

推荐答案

尝试是这样的:

try {
    // Convert from Unicode to UTF-8
    String string = "abc\u5639\u563b";
    byte[] utf8 = string.getBytes("UTF-8");

    // Convert from UTF-8 to Unicode
    string = new String(utf8, "UTF-8");

} catch (UnsupportedEncodingException e) {}

这篇关于获得使用谷歌地图API的Andr​​oid应用程序驾驶指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆