Gradle library. Android AutoCompleteTextView that receives and displays US address suggestions from SmartyStreets's US Autocomplete API.
SmartyStreet's Android SDK does not offer address suggestions, it only offers address verification and zip code lookup.
Yes, there is a demo app!
Demo app repository: https://github.com/RacZo/SmartyStreets-AutoComplete-Demo
If your app is already using the following SUPER AWESOME libraries:
- Google's Gson version 2.8.0 https://github.com/google/gson
- Square's okhttp version 3.6.0 https://github.com/square/okhttp
- Square's okhttp-logging-interceptor version 3.6.0 https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor
you are set! If not, add the following to your app's build.gradle:
compile 'com.google.code.gson:gson:2.8.'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
Via Gradle, by putting the following in your build.gradle:
compile 'com.oscarsalguero:smartystreetsautocomplete:1.0.1'
Or Maven:
<dependency>
<groupId>com.oscarsalguero</groupId>
<artifactId>smartystreetsautocomplete</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>
-
Sign up for an account on https://smartystreets.com and create a Website key (API key).
-
Do not forget to add
<uses-permission android:name="android.permission.INTERNET" />
to your app's Manifest.xml. -
Create an adapter class called "AddressAutocompleteAdapter" and make it extend "AbstractAddressAutocompleteAdapter", implement the required methods and define a layout for the dropdown item (R.layout.dropdown_text_item).
-
You will need your API key and a "referer" (host you entered when you created your key). The referer in your app must have "https://" as prefix or the API won't work.
<com.oscarsalguero.smartystreetsautocomplete.SmartyStreetsAutocompleteTextView android:id="@+id/autocomplete_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionHint="Number Street, City State" android:completionThreshold="1" android:hint="Address" android:maxLength="100" app:ssacv_adapterClass=".adapter.AddressAutocompleteAdapter" app:ssacv_referer="YOUR_REFERER" app:ssacv_suggestions="5" app:ssacv_webApiKey="YOUR_WEBSITE_KEY" />
-
To capture the address selection (when the user taps a suggestion) you'll use the provided listener:
autoCompleteTextView.setOnAddressSelectedListener(new OnAddressSelectedListener() { @Override public void onAddressSelected(@NonNull Address address) { } });
And... voilà!
- Fork this repo and clone your fork. Create an empty file called "bintray.gradle" in the root of your project.
- Make your desired changes
- Add tests for your new feature and ensure all tests are passing
- Commit and push
- Submit a Pull Request through Github's interface and I'll review your changes to see if they make it to the next release.
Use this repo's github issues.
SeatGeek's autocomplete library for Google Places https://github.com/seatgeek/android-PlacesAutocompleteTextView and the fact SmartyStreet's Android SDK does not offer address suggestions.
Copyright 2017 Oscar Salguero
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.