A simple library that can connect your autocomplete edittext to Google places api

Overview

Google Places AutoComplete EditText



A simple library that can connect your autocomplete edittext to Google's places api

        

Supporting Places AutoComplete EditText

Google Places AutoComplete EditText is an independent project with ongoing development and support made possible thanks to donations made by these awesome backers. If you'd like to join them, please consider:

How to integrate into your app?

Integrating the project is simple a refined all you need to do is follow the below steps

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.mukeshsolanki:Google-Places-AutoComplete-EditText:<latest-version>'
}

How to use the library?

Okay seems like you integrated the library in your project but how do you use it? Well its really easy just add the following to your xml design

.....
 <AutoCompleteTextView
    android:id="@+id/autoCompleteEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
.....

To connect the AutoCompleteTextView to the places api create a PlaceApi object and attach it to the AutoCompleteTextView like-wise

 val placesApi = PlaceAPI.Builder().apiKey("YOUR_API_KEY").build(this@MainActivity)
 autoCompleteEditText.setAdapter(PlacesAutoCompleteAdapter(this, placesApi))

That's pretty much it and your all wrapped up. You have successfully connected the Places Api to the AutoCompleteTextView.

Getting details of place

To get the selected address simply set an ItemClickListener

autoCompleteEditText.onItemClickListener =
      AdapterView.OnItemClickListener { parent, _, position, _ ->
        val place = parent.getItemAtPosition(position) as Place
        autoCompleteEditText.setText(place.description)
      }

To get the details of the place selected you can set a listener to get the details

placesApi.fetchPlaceDetails("placeId", object : OnPlacesDetailsListener {
      override fun onError(errorMessage: String) {
        Toast.makeText(this@MainActivity, errorMessage, Toast.LENGTH_SHORT).show()
      }

      override fun onPlaceDetailsFetched(placeDetails: PlaceDetails) {
        //TODO do anything with placeDetails object
      }
    })

Places details you can get

Details Value
id get the record id (not to be confused with the place id)
name gets the name of the place
address gets a list of different address types like street number, route, locality, country, postal code
lat gets the latitude of the place
lng gets the longitude of the place
place id gets the id of the place
url gets the maps url of the place
utc offset gets the utc offset of the place
vicinity gets the vicinity of the place
compound plus code gets the expanded Google plus code
global plus code gets the shortened Google plus code

Author

Maintained by Mukesh Solanki

Contribution

GitHub contributors

License

MIT License

Copyright (c) 2019 Mukesh Solanki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Java code?

    Java code?

    Hi,

    I was wondering if I can use your package with java? I tried but got stuck at the PlaceAPI.builder part.

    Is it supported and if so, could you provide the code?

    Would be a big help, really looking to implement something like this instead of the usual AutoCompleteSupportFragment.

    Thanks in advance.

    stale 
    opened by Luuk99 3
  • Very heavy CPU use, slows down app downloading map tiles when visible

    Very heavy CPU use, slows down app downloading map tiles when visible

    Subject of the issue

    During the time that the widget is active, CPU use is very high

    Steps to reproduce

    Open widget on UI surface

    Expected behaviour

    The CPU use should be more inline with Google's widget

    Actual behaviour

    UI is very slow to respond, loading map tiles while this widget is displayed, tile loading runs at a snails pace. The same scenario, but using Google's widget is undetectable to UI response.

    bug 
    opened by kenargo 2
  • Places SDK

    Places SDK

    what Places sdk version are you using (The Google Play Services version or new)? Asking as " The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019 "

    stale 
    opened by Popda 2
  • Situation were there is no plus_code

    Situation were there is no plus_code

    To replicate the issue search for address "Dhapasi, Nepal"

    Proposed changes

    Handle case when plus_code is not available in json response

    Types of changes

    What types of changes does your code introduce? Put an x in the boxes that apply

    • [☑ ] Bugfix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist

    Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

    • [ ] I have read the CONTRIBUTING doc
    • [ ] I have added necessary documentation (if appropriate)
    • [ ] Any dependent changes have been merged and published in downstream modules

    Further comments

    If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

    stale 
    opened by bishwash-adhikari 2
  • What's the <latest-version> in build.gradle dependency?

    What's the in build.gradle dependency?

    I tried entering version of the app i.e. "1.0" as well as the latest version of Google places API. But neither did work. Would you mind telling me what should I enter in the @mukeshsolanki? Thanks

    dependencies {
            implementation 'com.github.mukeshsolanki:Google-Places-AutoComplete-EditText:**<latest-version>**'
    }
    
    opened by nottherealironman 1
  • using this library sometimes places is getting and sometime not getting.why?

    using this library sometimes places is getting and sometime not getting.why?

    Subject of the issue

    Describe your issue here.

    Steps to reproduce

    Tell us how to reproduce this issue. Please provide a working demo.

    Expected behaviour

    Tell us what should happen

    Actual behaviour

    Tell us what happens instead

    bug 
    opened by BhargaviSunku 1
  • PlacesAutoCompleteAdapter cannot be found

    PlacesAutoCompleteAdapter cannot be found

    Added the library and created the PlaceApi object, but the adapter to be attached to the autocompletetextview cannot be found. I tried clearing cache and restarting but it doesnt work.

    bug 
    opened by vxplore 0
  • Master

    Master

    Proposed changes

    Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

    Types of changes

    What types of changes does your code introduce? Put an x in the boxes that apply

    • [ ] Bugfix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist

    Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

    • [ ] I have read the CONTRIBUTING doc
    • [ ] I have added necessary documentation (if appropriate)
    • [ ] Any dependent changes have been merged and published in downstream modules

    Further comments

    If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

    opened by mukeshsolanki 0
  • Session-Tokens

    Session-Tokens

    Proposed changes

    Adding the ability to added session tokens. Resolves #2

    Types of changes

    What types of changes does your code introduce? Put an x in the boxes that apply

    • [ ] Bugfix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist

    Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

    • [x] I have read the CONTRIBUTING doc
    • [x] I have added necessary documentation (if appropriate)
    • [x] Any dependent changes have been merged and published in downstream modules

    Further comments

    If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

    opened by mukeshsolanki 0
  • minor refactoring

    minor refactoring

    Proposed changes

    This refactors and removed the repeated code

    Types of changes

    What types of changes does your code introduce? Put an x in the boxes that apply

    • [x] Refactoring (non-breaking changes)
    • [ ] Bugfix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist

    Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

    • [x] I have read the CONTRIBUTING doc
    • [x] I have added necessary documentation (if appropriate)
    • [x] Any dependent changes have been merged and published in downstream modules
    opened by mukeshsolanki 0
  • Powered by google

    Powered by google

    Proposed changes

    Adds Powered by Google Footer ( Resolves #1 )

    Types of changes

    What types of changes does your code introduce? Put an x in the boxes that apply

    • [x] Bugfix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist

    Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

    • [x] I have read the CONTRIBUTING doc
    • [x] I have added necessary documentation (if appropriate)
    • [x] Any dependent changes have been merged and published in downstream modules
    opened by mukeshsolanki 0
  • Add support for optional parameters

    Add support for optional parameters

    Could you please add support for the optional parameters to the libraray? (https://developers.google.com/maps/documentation/places/web-service/autocomplete)

    I am specifically looking for support to limit the autocomplete results to specific countries (components=country:) and to only show address/city/state/country.

    enhancement 
    opened by ThorinHanson 0
  • Country filter

    Country filter

    Is your feature request related to a problem? Please describe. I cannot restrict the search to a specific country. I would like to restrict the search to India as other country results are of no use to me

    Describe the solution you'd like We have setCountry(...) in default AutocompleteSupportFragment so it would be nice to have that feature in this library as well

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement 
    opened by braj008 0
  • User can dismiss ...

    User can dismiss ...

    When the dropDown menu appears, the user can dismiss it with a touch outside and the api request will not give results , is there any way to check if the api request was made or not ?

    enhancement 
    opened by Dave181295 0
  • Search radius

    Search radius

    Thanks for your awesome library!

    it would be awesome if you can add a parameter to put the cords of the user so when he search automatically he got hes near address by radius (e.g 500meters, 1km , etc..) instead of showing all the world's addresses.. ^^

    enhancement 
    opened by Dave181295 0
  • More than one file was found with OS independent path 'META-INF/library_release.kotlin_module'

    More than one file was found with OS independent path 'META-INF/library_release.kotlin_module'

    
    Execution failed for task ':app:mergeDebugJavaResource'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
       > More than one file was found with OS independent path 'META-INF/library_release.kotlin_module'.
    
    
    
    bug 
    opened by Dave181295 0
Owner
Mukesh Solanki
Mukesh Solanki is a full-stack developer from Bangalore, India.
Mukesh Solanki
A flutter plugin to scan stripe readers and connect to the them and get the payment methods.

stripe_terminal A flutter plugin to scan stripe readers and connect to the them and get the payment methods. Installation Android No Configuration nee

Aawaz Gyawali 8 Dec 29, 2022
An extension of EditText with pin style written in Kotlin

pin-edittext An extension of EditText with pin style Usage Include PinCodeEditText in your layout XML <com.oakkub.android.PinEditText android:layo

Metas Kerdwat 15 May 28, 2021
This program will read from your android application string.xml file and generate translated strings.xml files in your preferred languages using google sheet.

Localize your application content This program will read from your application string.xml file and generate translated strings.xml files in your prefe

DhiWise 4 Jul 29, 2022
GBooks - A simple android app written in Kotlin to read books from the Google Book Api

G-Books A simple android app written in Kotlin to read books from the Google Boo

Google Developer Student Clubs - Baba Banda Singh Bahadur Engineering College 10 Nov 7, 2022
UserLoc - A API call using Retrofit to obtain list of users details and show on UI in recycler view and google map

UserLoc This uses a API call using Retrofit to obtain list of users details and

Rohit Kumar 0 Jun 22, 2022
Arc Layout is a view group with which you can add a arc-shaped container in your layout.

ArcLayout Arc Layout is a view group with which you can add a arc-shaped container in your layout. Two main variables are the direction and the curvat

Ali Rezaiyan 32 Aug 17, 2022
DocuBox is a cloud based file storing app where you can securely store and access your documents from anywhere around the world

DocuBox is an android app ??in which you can securely upload your files on the cloud– from family pictures and audio recordings to spreadsheets, presentations and other confidential documents.

Vaibhav Jaiswal 26 Jan 3, 2023
DI can be simple. Forget about modules and components. Just use it!

PopKorn - Kotlin Multiplatform DI PopKorn is a simple, powerful and lightweight Kotlin Multiplatform Dependency Injector. It doesn't need any modules

Pau Corbella 145 Dec 25, 2022
A simple demo that shows how WebWorkers can be used in Kotlin/JS

Web Workers in KotlinJS This repo demonstrates how to set up a Web Worker in Kotlin/JS. It is a very simple demo that creates a new worker that sends

Ethan Davidson 7 Dec 15, 2022
Simple Design for Kotlin bridge with Javascript. Also can get javascript console.log.

SDBridgeJava is here. If your h5 partner confused about how to deal with iOS and Android. This Demo maybe help. bilibili video introduction is here. Y

null 14 Dec 19, 2022
API-Annotate - Single annotation to mark API elements

API-Annotate A single annotation for annotating externally-consumed elements in

null 0 Feb 5, 2022
API-Request - Android app that makes API Request

API-Request Android project using Retrofit and Ktor for Http Requests, built wit

Thales 2 Mar 26, 2022
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

EasyPermissions-ktx Kotlin version of the popular googlesample/easypermissions wrapper library to simplify basic system permissions logic on Android M

Madalin Valceleanu 326 Dec 23, 2022
A Kotlin multiplatform unit testing library inspired by / similar to Google Truth.

Truthish A testing API inspired by Google Truth but rewritten in Kotlin from the ground up, so it can be used in Kotlin multiplatform projects. For ex

Varabyte 70 Nov 2, 2022
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

Darwin Francis 58 Nov 1, 2022
Simple MVVM app to get photos through https://unsplash.com api

MyPhotoLoaderApp Simple photo loading app powered by Unsplash.com which implements MVVM architecture using Hilt, Navigation Component, Retrofit, Pagin

Behnam Banaei 10 Oct 6, 2022
Simple android application that consumes Rick and Morty API to display characters,episodes,Location

Rick and Morty Compose An android app built using Kotlin that consumes Rick and

Michael Ndiritu 68 Nov 23, 2022
Crunch-Mobile - A Food Delivery Mobile App which uses Modern App Architecture Pattern, Firebase And a Simple Restful Api

Crunch-Mobile This is a Food Delivery Mobile App which uses Modern App Architect

Bright Ugwu 1 Jan 1, 2022