6

Per policy it is mandatory show "html_attributions" in the app. This response is received as - "html_attributions" : [ "Listings by \u003ca href=\"http:// Some website.com/\"\u003esSome website\u003c/a\u003e" ]

When I parse it as jObject.getJSONArray("html_attributions") I get - ["Listings by <a href=\"http:\/\/www.some website.com\/\">some website<\/a>"]

This cannot be displayed as is since it is not html correct. Is there any method to parse this attribution correctly so that html valid string is extracted?

user1930106
  • 779
  • 1
  • 6
  • 19
  • have you found solution? I suggest it is in xml format so parse that html_attributions in xml parsing. which will give you link for that – Max Dec 15 '15 at 12:55

2 Answers2

1

Go through this Google Places Api Sample which describes a way of doing so.

It has a method formatPlaceDetails that Format details of the place for display. It does not support HTML tags directly, they need to be encoded first.

private static Spanned formatPlaceDetails(Resources res, CharSequence name, String id,
            CharSequence address, CharSequence phoneNumber, Uri websiteUri) {
        Log.e(TAG, res.getString(R.string.place_details, name, id, address, phoneNumber,
                websiteUri));
        return Html.fromHtml(res.getString(R.string.place_details, name, id, address, phoneNumber,
                websiteUri));

    }

string.xml

<string name="place_details">&lt;b&gt;%1$s&lt;/b&gt;&lt;br/&gt;&lt;i&gt;Place Id: %2$s&lt;/i&gt;&lt;br/&gt;Address: %3$s&lt;br/&gt;Phone: %4$s&lt;br/&gt;Website: %5$s</string>
Vipul Asri
  • 8,903
  • 3
  • 46
  • 71
0

It may help

From google I have found this on this page. Which is html tag and if we want exact url than we have to get from that html string parsed from xml.

 This is an example of an attribution in JSON format:

"html_attributions" : [
      "Listings by \u003ca href=\"http://www.example.com/\"\u003eExample Company\u003c/a\u003e"
],

This is an attribution in XML format:
<html_attribution>Listings by <a href="http://www.example.com/">Example Company</a></html_attribution>
Max
  • 2,269
  • 4
  • 24
  • 49