Android library that allows you to determine your location in a few of lines

Related tags

Maps locsimple
Overview

locsimple

locsimple

Android library that allows you to determine your location in some lines!

Benefits:

  • automatic processing of permissions
  • processing of enabling and disabling the transfer of location data on the device
  • android 12 support
  • you can customize the location service more precisely
  • additional callbacks
  • support for Huawei devices without Google services

My lib consists of three modules:

  • location-google: location using Google services (only works on devices with google services)
  • location-huawei: location using Huawei services
  • location-google-huawei: uses Google services if available otherwise Huawei services

Use one of them.

Get started

Define my location:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val locationText = findViewById
   
    (R.id.location_text)

        // use LocationSimpleSingle to determine the location once (in most cases)
        val simple = LocationSimpleSingle(this)
        
        // location is android.Location object
        simple.defineLocation { location ->
            locationText.text = "${location.latitude}\n${location.longitude}"
        }
    }
}

   

Listen location changes:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val locationText = findViewById
   
    (R.id.location_text)
        
        // use LocationSimpleMultiple to listen to a new location (only foreground)
        val simple = LocationSimpleMultiple(this)
        
        // location is android.Location object
        simple.defineLocation { location ->
            locationText.text = "${location.latitude}\n${location.longitude}"
        }
    }
}

   

Additional callbacks:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val locationText = findViewById
   
    (R.id.location_text)

        val simple = LocationSimpleSingle(this)

        simple.onPermissionDenied { 
            // permission is denied
        }

        simple.onLocationShutdown { 
            // location mode is off
        }

        simple.defineLocation { location ->
            locationText.text = "${location.latitude}\n${location.longitude}"
        }
    }
}

   

Customizing the location service:

 class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val locationText = findViewById
   
    (R.id.location_text)

        // use NeededLocationPermission to indicate an exact or inaccurate location (on android 12 is ignored)
        // use LocationRequestSettings to customize the location service
        val simple = LocationSimpleMultiple(this, NeededLocationPermission.EXACTLY, LocationRequestSettings()
            .changedInterval(5000L)
            .changedFastestInterval(1000L)
            .changedPriority(LocationPriority.HIGH_ACCURACY))

        simple.defineLocation { location ->
            locationText.text = "${location.latitude}\n${location.longitude}"
        }
    }
}

   

Learn more about LocationRequestSettings options see link

Download

I don't know how to add my lib to the maven repository yet, so you can only download the source code and follow the video instructions:

demo

You might also like...
Maps SDK for Android Utility Library
Maps SDK for Android Utility Library

Maps SDK for Android Utility Library Description This open-source library contains utilities that are useful for a wide range of applications using th

A library for reverse geocoding coordinates in Android

๐Ÿ“ AndroidReverseGeocoder A library for reverse geocoding coordinates in Android. The library is built on top of android's Geocoder library. AndroidRe

Maps application in Android Studio using the Maps SDK for android

Google-Maps-Application Maps application in Android Studio using the Maps SDK for android. This app was initially developed in Java, but then was conv

Scale bar for Android Maps (Google Maps, OSM, MapBox, Yandex)
Scale bar for Android Maps (Google Maps, OSM, MapBox, Yandex)

Map Scale View Scale view for any Android Maps SDK (not only Google Maps) Contributing I encourage you to participate in this project. Feel free to op

DrawRoute wraps Google Directions API (https://developers.google.com/maps/documentation/directions/) using RxJava for Android so developers can download, parse and draw path on the map in very fast and flexible way (For now only JSON support). Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.

This is a repo for implementing Map pan or drag (up, down, right ,left) to load more places on the Google Map for Android

Challenge Display restaurants around the userโ€™s current location on a map โ—‹ Use the FourSquare Search API to query for restaurants: https://developer.

Membuat Aplikasi Pencarian Bengkel dan Tambal Ban dengan Android Studio
Membuat Aplikasi Pencarian Bengkel dan Tambal Ban dengan Android Studio

Tambal-Ban Membuat Aplikasi Pencarian Bengkel dan Tambal Ban dengan Android Studio Tutorial Build with Android Studio https://youtu.be/82L7az6hdVI Tut

๐Ÿƒ Organic Maps is an Android & iOS offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by MapsWithMe founders.
๐Ÿƒ Organic Maps is an Android & iOS offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by MapsWithMe founders.

๐Ÿƒ Organic Maps is an Android & iOS offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by MapsWithMe founders. No ads, no tracking, no data collection, no crapware.

Owner
Dmitry
Android developer, Java/Kotlin coder, author, blogger and just a good person
Dmitry
App usage tracker which maps your app usage to geo location.

Guilt Guilt is an inspiration from Meta (pun intended), it tracks the apps usage and maps it with geo location data where the app was last used. The a

null 6 Dec 28, 2022
Positional is a location information app for Android with Compass, Clock, Level, Sun and Moon and many other features.

Positional is a location based app that utilizes the device's GPS and fetches various details of the current latitude and longitude data like Altitude, Speed, Address and similar other information and show it in easily understandable format to the user. Alongside this main functionality of being a location app, Positional also provides a separate panel for Compass and Clock, and they serve their own purpose as their name suggests.

Hamza Rizwan 85 Dec 28, 2022
An android app that uses Google Maps API and SDK to track a user's location and calculate the total distance travelled

Bike Rush is an android app that uses Google Maps API and SDK to track a user's location and calculate the total distance travelled by him or her along with time and average speed.

Ishant Chauhan 21 Nov 14, 2022
LocationPicker 2.1 0.4 Java - A simple and easy to way to pick a location from map

Introduction LocationPicker is a simple and easy to use library that can be integrated into your project. The project is build with androidx. All libr

Shivpujan yadav 61 Sep 17, 2022
My Maps displays a list of maps, each of which show user-defined markers with a title, description, and location. The user can also create a new map. The user can save maps and load them in from previous usages of the app.

My Maps Bryant Jimenez My Maps displays a list of maps, each of which show user-defined markers with a title, description, and location. The user can

null 0 Nov 1, 2021
This project allows you to calculate the route between two locations and displays it on a map.

Google-Directions-Android This project allows you to calculate the direction between two locations and display the route on a Google Map using the Goo

Joel Dean 970 Dec 15, 2022
EasyRoutes allows you to easily draw routes through the google maps address api.

EasyRoutes EasyRoutes allows you to easily draw routes through the google maps address api. Note: You need to generate an API key from the google cons

Antonio Huerta Reyes 7 Jul 26, 2022
BlueMap addtion plugin. Add a marker command to the game to easily setup your markers ingame without touching configs

BlueMap Marker Manager -> Download BlueMap here BlueMap supports a variety of marker setups by default, but it requires some work from editing configs

Miraculixx 6 Dec 3, 2022
Android Maps Extensions is a library extending capabilities of Google Maps Android API v2.

Android Maps Extensions Library extending capabilities of Google Maps Android API v2. While Google Maps Android API v2 is a huge leap forward comapare

Maciej Gรณrski 408 Dec 15, 2022
Curve-Fit is an Android library for drawing curves on Google Maps

Curve-Fit Android library for drawing curves on Google Maps. This library uses Bezier cubic equation in order to compute all intermediate points of a

Sarweshkumar C R 63 Mar 7, 2021