Get driving instructions on an Android app using the Google Directions API

I have this Android application where I have to show users the routes. For this, I use the Google Directions API. This includes querying their URL and getting JSON as a result. Now the problem is this: the directions of movement are inside the TAG / Name - "html-instructions". Here I get directions, but it is embedded in Unicode characters, for example.

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

How can I get rid of these unicode values ​​and get plain text from it.

Please, help

+3
source share
2 answers

- :

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) {}
0

direcObject.getString( "html_instructions" ). replaceAll ( "\ <. *? > ", "") html

0

All Articles