Reputation: 22064
I have never used Google Places before and thought it would be time to do so. I've followed this tutorial: http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/
My problem is when I'm creating this method createRequestFactory()
it says that JsonHttpParser
class is now deprecated. I've looked everywhere to find an alternative solution, but haven't been able to do so. I'm targeting Android 2.1 and developing in Eclipse Juno. Does anyone have any clue on how to resolve this conflict? I don't get any compiling errors, and eclipse is building it without any problems, but I don't want to use this deprecated class.
Here's my code:
public static HttpRequestFactory createRequestFactory(
final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName("AndroidHive-Places-Test");
request.setHeaders(headers);
// deprecated this last two lines
JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
request.addParser(parser);
}
});
}
Thanks in advance!
Upvotes: 1
Views: 804
Reputation: 22064
try{
HttpPost httppost = new HttpPost(googleSearchPlaceUrl);
HttpClient httpclient = new DefaultHttpClient();
response = httpclient.execute(httppost);
String data = EntityUtils.toString(response.getEntity());
//parse with Json
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 1
Reputation: 1418
You have to use JsonObjectParser instead of JsonHttpParser
JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
Upvotes: 0