Skip to content

Intuz-production/AddressPicker-Android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

INTUZ is presenting an interesting Address Picker component to integrate inside your Native Android based application. Address Picker is a simple component, which lets you pick a location from map and search using Google Places API. You will get a latitude, longitude and full address for selected location.

Please follow the below steps to integrate this control in your project.



Features

  • Easy & Fast to retrive location.
  • You can select a location from Google Place API or User’s current location.
  • Can Customize according to requirement.



Getting Started

To use this component in your project you need to perform below steps:

  1. Configure your app in Google API Console to get API Key and enable services.

https://console.cloud.google.com/apis/dashboard

  1. Enable below services in API Console.
  Google Maps Android API
  
  Google Places API for Android
  
  1. Permission and declaration in AndroidManifest.xml file
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Note: replace ‘’ with your google api key in manifeast.xml file.

  1. Start Address picker request by putting below code in your view :
                  Intent intent = new Intent(MainActivity.this, LocationPickerActivity.class);
                  startActivityForResult(intent, ADDRESS_PICKER_REQUEST);

  1. Handle your onActivityResult for getting address, latitude and longitude as:
     @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == ADDRESS_PICKER_REQUEST) {
            try {
                if (data != null && data.getStringExtra("address") != null) {
                    String address = data.getStringExtra("address");
                    double currentLatitude = data.getDoubleExtra("lat", 0.0);
                    double currentLongitude = data.getDoubleExtra("long", 0.0);
                    txtAddress.setText("Address: "+address);
                    txtLatLong.setText("Lat:"+currentLatitude+"  Long:"+currentLongitude);

                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
    



Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.



License

The MIT License (MIT)

Copyright (c) 2018 INTUZ

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 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.

Releases

No releases published

Packages

No packages published

Languages