Google Places API Android Integration

I'm trying to integrate Google Places API into my already existing maps fragment, however I'm finding Googles own guide is rather confusing, and the project samples they have provided don't seem to integrate with Android studio very well (I'm assuming it's something to do with the framework/gradle). Are there any other samples/tutorials that I can use for assistance? Here is my current file structure: Google Places API Android Integration

and menu_1_fragment is where GoogleMaps integrates and loads into the project. This is what the code looks like:

package com.examples.blahblah.blahblah; import android.app.Fragment; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapsInitializer; import com.google.android.gms.maps.model.LatLng; public class menu_1_fragment extends Fragment { MapView mapView; GoogleMap map; // private GoogleApiClient mGoogleApiClient; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.menu1_layout, container, false); /*mGoogleApiClient = new GoogleApiClient .Builder(this) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); */ // Set's the Title // 3 SPACES to the right. getActivity().getActionBar().setTitle(" MapView"); // Set's the Icon getActivity().getActionBar().setDisplayShowHomeEnabled(true); getActivity().getActionBar().setLogo(R.mipmap.ic_launcher); getActivity().getActionBar().setDisplayUseLogoEnabled(true); try { MapsInitializer.initialize(getActivity()); } catch (GooglePlayServicesNotAvailableException e) { Log.e("Address Map", "Could not initialize google play", e); } switch (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity())) { case ConnectionResult.SUCCESS: Toast.makeText(getActivity(), "Welcome to NightCentral", Toast.LENGTH_SHORT).show(); mapView = (MapView) v.findViewById(R.id.map); mapView.onCreate(savedInstanceState); // Gets to GoogleMap from the MapView and does initialization stuff if (mapView != null) { map = mapView.getMap(); map.getUiSettings().setMyLocationButtonEnabled(true); map.setMyLocationEnabled(true); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(-37.813611100000000000, 144.963055599999960000), 10); map.animateCamera(cameraUpdate); } break; case ConnectionResult.SERVICE_MISSING: Toast.makeText(getActivity(), "SERVICE MISSING", Toast.LENGTH_SHORT).show(); break; case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED: Toast.makeText(getActivity(), "UPDATE REQUIRED", Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(getActivity(), GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()), Toast.LENGTH_SHORT).show(); } return v; } /* @Override protected void onStart() { super.onStart(); mGoogleApiClient.connect(); } @Override protected void onStop() { mGoogleApiClient.disconnect(); super.onStop(); } */ @Override public void onResume() { mapView.onResume(); super.onResume(); } @Override public void onDestroy() { super.onDestroy(); mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); mapView.onLowMemory(); } }

What else do I need to include to get places working with Maps? I Eventually want to use the UI picker and include a near me function. I've commented some parts out from my previous attempts to include places. Do I perhaps need to import some other files into my project dependencies?

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:22.1.1' compile 'com.google.android.gms:play-services:4.0.30' compile 'com.facebook.android:facebook-android-sdk:4.0.0' // compile 'com.google.android.gms:play-services:7.3.0' }

Thanks again guys.

Category:java Views:4 Time:2016-11-23

Related post

  • Google Places API (Android) INVALID_REQUEST - am I missing something? 2014-09-18

    I'm working with Places API and I'm getting INVALID_REQUEST when I try to check for nearby places. Here's a snippet of my code - is there anything wrong with this? Am I missing something? urlString.append("&location="); urlString.append(Double.to

  • Google Places API - android 2012-01-26

    I am making an android application that needs to search in my local area within 10km and display the results onto a map using pins, For example: "Starbucks", "Wallmart", Shopping mall, etc. The search word that i specify in my activity class. And to

  • Using Google Places API in Android 2010-09-30

    I am trying to develop an app which can display the schools and airports in the locality. I found that using Google Places API is the way to go... I have seen the documentation here... But anyone could please simply the use of the API. Any tutorials

  • Problem with introducing-google-places-api example in android 2011-06-17

    I'm trying to use Google Places API through Google APIs Client for an Android app. I've found this example: http://ddewaele.blogspot.com/2011/05/introducing-google-places-api.html and launching like java application runs OK, so I must have a right AP

  • Using JSON Response from Google Places API in Android 2011-08-12

    I want to do some application to learn how to work with android and maps. So I want to make something simple, like showing on the map the schools or museums from a given city. I think I have to use the Google Places API, so I read some things about i

  • Can i use google Places API in android? 2011-10-25

    I have written an java application that uses Google Places Api (i added the api as an external library in Eclipse). I am able able to get places in a given radius. My project is not desktop based though, it should be an android phone based. Can i imp

  • Android - admob publisher id and google places api key 2011-11-15

    I have following 2 doubts related to keys in admob and google places api key- 1.Can I use single admob publisher id in multiple application. Will that create any problem or I have to create separate publisher id for each app. 2.If I want to create 5

  • Adding you own place using Google places API in android 2012-03-12

    i want to add my own place using Google places API in android I am using the following code snippet, however it give me this exception: com.google.api.client.http.HttpResponseException: 400 Bad Request My code snippet is: private static final String

  • Google Places API in Android 2012-03-25

    I am not getting the result after running this code. package com.google.autocomplete; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.

  • Adding description while adding your own place using Google places API in Android 2012-03-30

    I want to add my own place using Google places API in android with some description. Now i want to add vicinity, URL, Website, international_phone_number etc in the string format below but i am unable to get it plz help me: String placeJSON = "{"+ "\

  • How to integrate Google place API in android 2012-04-27

    I want to show user location and near by places like ATM,Restaurant,Gas Station etc in my android application.I am come to know that there is such an API in Google called Google place API to do the same,but i do not know how to integrate the same in

  • How to get JSON response from google places API in android? 2015-02-09

    Can anyone share a snippet that elaborates how to get JSON response ( IN ANDROID) from call to Google Places API? How do I call API? How do I pass parameters and How do I get JSON response? --------------Solutions------------- You could take a look a

  • Android Difference between google local search and google places api 2011-11-07

    I am developing app similar to restaurant locator or bank locator. I was looking through examples of google places api. But then I noticed google local search using this url http://ajax.googleapis.com/ajax/services/search/local. I want to know what i

  • Accesing Google Places API in android 2011-11-09

    Hi Guys I am working on an application which uses google places API. I got API key for my application,but the problem is I am getting ZERO_RESULTS as a response from the sever. Here is my code I used DefaultHttpClient to establish the http connection

  • Showing details of place using Google Places API in Android 2012-03-27

    I am using Google Places API to search for particular places, add my own places, view details of places and delete places. Now when I want to see details of place I am passing “HARD CODED reference” of places and I am able to see details that work fi

  • Android: Updating a ListView when the content of a SearchView is changed with results from Google Places API 2014-12-15

    I am trying to update a ListView with Google Places API when the value of the SearchView is changed. There is a problem when the list view gets updated. Here is my class, SearchFragment. https://gist.github.com/anonymous/d5fc885cca8426736888 onListIt

  • Google Places API in iOS application 2011-04-04

    Let me share my findings before asking the question. Google Places API documentation says: "Note: To use the Google Places API you must first request a Maps API client ID and cryptographic key which you must use to sign your request URLs. For informa

  • Using Google Places API 2011-04-05

    I want to develop an application in which i want to display information about places nearby (within 1km )the user by getting its current location.. Say for example i want to display information about Restaurants, Shopping Malls, Hospitals located wit

  • Google Places API request Call 2011-05-28

    i've been struggeling with this all day now I want to make an API call to Google Places but i can't seem to figure it out. I've tried this: http://blog.brianbuikema.com/2010/08/android-development-part-1-using-googles-places-api-to-develop-compelling

  • Better Understanding Using Google Places Api 2011-06-18

    I want to develop an application in which i want to display restaurants nearby the user. Say for example i want to display name and address of restaurants located within 3km related to current location of the android device.. I have done alot of read

  • Google Places API, only in US? 2011-08-09

    I am trying to develop an app in Android which can display information about places nearby but after several tries it seems the Google Places API can only shows information within US. It works good when the place is in US, I can get nearby shops,bank

  • Can insert our custom data of places in google places api? 2011-11-28

    Many of you has worked on LBS application in android and also used the Google Places API web service for the information of various places. And you may also noticed that the data for India specifically is not accurate means many of places that you kn

  • REQUEST_DENIED when using the Google Places API 2011-12-08

    I'm trying to make a request to the Google Places API, using the following url: https://maps.googleapis.com/maps/api/place/search/xml?location=37.77264,-122.409915&radius=500&types=educational%20services&name=everest%20college%20san%20fra

  • Google Places API results in ListView 2011-12-15

    I am writing an app where I am searching for local restaurants (around where the device is at the moment). I was advised to check out Google Places API. However, I am in a college town and it seems that many of the places I want to be searched are no

  • use google places API to find "pizza near austin, tx" 2011-12-22

    I am writing a simple Android app with an EditText and a MapView. I want to be able to type "pizza near austin, tx", and have the map zoom to pizza places in Austin, TX. I am using the Google API Java Client to send a request to Google Places API, an

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.128 (s). 11 q(s)