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

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

A Mixin framework for Spigot/Bukkit that allows you to hook custom event anywhere

A Mixin framework for Spigot/Bukkit that allows you to hook custom event anywhere

A Mixin framework for Spigot/Bukkit that allows you to hook custom event anywhere. Start coding your advanced plugins today!

Nov 30, 2022

1.7 - 1.18 utility class that allows you to change blocks at blazing fast speeds

BlockChanger 1.7 - 1.18 utility class that allows you to change blocks at blazing fast speeds Setup Just import the class to your project. Usage Playe

Dec 23, 2022

A simple app that allows you to view high quality aerial photos of Poland

A simple app that allows you to view high quality aerial photos of Poland

kalucky0 Maps A simple app that allows you to view high quality aerial photos of Poland Data source: Geoportal Contributing Contributions are always w

Apr 15, 2022

A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

BtAssetManager This application allows you to easily categorize large amounts of image and sound files. You can apply tags to each individual file to

Sep 15, 2022

A small companion library to Mixin, designed to help you write your Mixins in a more expressive and compatible way.

MixinExtras A small companion library to Mixin, designed to help you write your Mixins in a more expressive and compatible way. More information about

Jan 7, 2023

With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Dec 21, 2022

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

GFX-AdPromote An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & nat

Dec 25, 2022

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Dec 30, 2022

tuya-spring-boot-starter helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilities. You can put all the focus on business logic without taking care of server-side programming nor relational databases.

English | 中文版 tuya-spring-boot-starter helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilit

Dec 26, 2022
Owner
Dmitry
Android developer, Java/Kotlin coder, author, blogger and just a good person
Dmitry
WordleCompanion - A tool to help you determine those hard-to-guess words while doing your daily Wordle puzzles.

A tool to help you determine those hard-to-guess words while doing your daily Wordle puzzles. How it works Enter the 5-letter word you

Ken Vaczi 1 Jan 22, 2022
Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Gabriele Rizzo 865 Jan 2, 2023
A minecraft minigame where you have to defend your bed and destroy the others. Once your bed is destroyed, you cannot respawn.

As from November 1st 2021 BedWars1058 by Andrei Dascălu becomes open source under GNU GPL 3.0 license. If you are a developer I would really appreciat

Andrei Dascălu 182 Dec 26, 2022
Get device location by telephony (SIM card) or settings without using GPS tracker.

react-native-device-country Get device location by telephony (SIM card) or settings without using GPS tracker Installation yarn add react-native-devic

dev.family 46 Nov 29, 2022
A Pomodoro Timer that allows you to collect Pokemon as you work.

Pomodoro: The Pokémon Collecting Game! A fun take on the Pomodoro Technique So, what does this application do? This application utilizes the famous Po

Kevin Wong 2 Jan 29, 2022
Allows you to use the MongoDB query syntax to query your relational database.

Spring Data JPA MongoDB Expressions How it works: Customize JPA Repository base class: @SpringBootApplication @EnableJpaRepositories(repositoryBaseCla

Muhammad Hewedy 86 Dec 27, 2022
A mod for OneConfig that allows you to customize the hit color of any living entity to your liking.

HitColor A mod for OneConfig that allows you to customize the hit color of any living entity to your liking. Features An option to toggle Armor being

Nox 4 Nov 5, 2022
Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile An exact copy of Your Information ! Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Installation

Sri lakshmi kanthan P 1 Sep 12, 2022
Create your Java crypto trading bot in minutes. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions so you can focus on building your strategies.

Quick Start | Documentation | Discord | Twitter Create and run your java crypto trading bot in minutes Our Spring boot starter takes care of exchange

Cassandre 442 Jan 3, 2023
DM Movie is an app with several movies catalogued through a database, you enter your email and your rating of the movie

DM Movie is an app with several movies catalogued through a database, you enter your email and your rating of the movie

Davi M. G. de Almeida 5 Jan 28, 2022