Location-permission-handler - Location Permission Handler For Android

Overview

Location Permission Handler

Easy way to check location permissions for Android 9/10/11 devices. Project can be integrated with your existing ones thanks to kotlin extension functions.

Usage

In your fragment, to check any permissions (not only location permissions) you can call directly with :

fun Fragment.handlePermission(
    permission: AppPermission,
    onGranted: (AppPermission) -> Unit,
    onDenied: (AppPermission) -> Unit,
    onRationaleNeeded: ((AppPermission) -> Unit)? = null
)

AppPermission class takes two parameters :

sealed class AppPermission(
    val permissionName: String,
    val requestCode: Int
)

Example usage in fragments :

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    handlePermission(
        AppPermission.ACCESS_COARSE_LOCATION,
        onGranted = { checkDeviceLocationSetting() },
        onDenied = { requestPermission(AppPermission.ACCESS_COARSE_LOCATION) },
        onRationaleNeeded = {  showToast("onRationaleNeeded")}
    )
}

Afterwards override onRequestPermissionsResult() in fragment :

override fun onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<out String>,
    grantResults: IntArray
) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    handlePermissionsResult(requestCode, permissions, grantResults,
        onPermissionGranted = { showToast("onPermissionGranted") },
        onPermissionDenied = { showToast("onPermissionDenied") },
        onPermissionDeniedPermanently = { showToast("onPermissionDeniedPermanently") }
    )
}

Acknowledgement

To-Do

  • Deprecated onRequestPermissionsResult will be replaced with registerForActivityResult()

Screenshots

You might also like...
Location Reminder App build as part of the udacity nanodegree program

Location Reminder a Location Reminder App with notifications that remind the user to do something when the user is at a specific location. built as pa

A simple xposed module that helps you fully control your location.

FuckLocation An simple xposed module that helps you fully control your location. 一个可以帮助你完全控制位置授权的模块 Currently, you may return custom location to speci

Sample Project with Clean Architecture for demonstrating using Kotlin Flows for fetching User Location and networking.

Nearby-Places-Foursquare-Android Getting Nearby Places using Foursquare API API's Used from FourSquare Get Key from Foursquare site. NearBy places Her

Android MVVM framework write in kotlin, develop Android has never been so fun.

KBinding 中文版 Android MVVM framework write in kotlin, base on anko, simple but powerful. It depends on my another project AutoAdapter(A library for sim

Klimatic is an android app built using Kotlin. It try to showcase all the latest technologies used in android.
Klimatic is an android app built using Kotlin. It try to showcase all the latest technologies used in android.

Klimatic Klimatic is an android app built using Kotlin. It try to showcase all the latest technologies used in android. Built using Android Architectu

Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

This is a demo android app representing implementation of SE principles in android app development

Articles Demo This repository contains a sample Android App that shows most popular articles data from NY Times API. This is a sample app that shows h

Android-Boilerplate - Base project for android development with new technology

Android-Boilerplate Base project for android development with new technology, in

Gits-android-extensions - A collection of Kotlin extensions to simplify Android development

gits-android-extensions A collection of Kotlin extensions to simplify Android de

Owner
null
An Awesome Kotlin Location library to retrieve location merely in 3 lines of code

An Awesome Kotlin Location library to retrieve location merely in 3 lines of code

Birju Vachhani 288 Dec 30, 2022
Location-history-viewer - Small compose-desktop app to view data from google's location history

Google Location History Takeout Viewer This application provides a minimalistic

Chris Stelzmüller 3 Jun 23, 2022
Permissionmanager is a small wrapper for handling permission requests.

Permissionmanager Permissionmanager is a small wrapper for handling permission requests. Installation Add jitpack to your repositories in Project buil

Thomas Cirksena 11 Nov 17, 2020
:closed_umbrella: An easy way to implement modern permission instructions popup.

Needs An easy way to implement modern permission instructions popup. Needs can be fully customized and showing with animations. Download Gradle Add be

Jaewoong Eum 609 Dec 8, 2022
Show weather data for the current location [Apollo Agriculture Interview Solution], for the Senior Android Engineer Role

Apollo Agriculture Android Take Home Assignment Writing Apollo Agriculture App using Android Architecture Components, in 100% Kotlin, using Android Je

Juma Allan 23 Nov 23, 2022
Location Service Manager for Kotlin Multiplatform Mobile iOS and android

Location Service Manager for Kotlin Multiplatform Mobile iOS and android Features Provides simple permission settings Dramatically reduce the amount o

LINE 55 Dec 10, 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
Whereabouts: an android library which leverages Kotlin concurrency to streamline location fetching

Whereabouts Whereabouts is an android library which leverages Kotlin concurrency

Sumeet Rukeja 1 Jul 5, 2022
The Superhero app keeps track of the near real-time location of all the volunteers.

Superhero The Superhero app keeps track of the near real-time location of all the volunteers. The app sends requests for emergency tasks to nearby vol

CoronaSafe Network 4 May 3, 2022
find the top coffee shop near by a given location

YelpCoffee&Tea 2 Different Activities (Screens): coffee shop List, coffee shop detail View Android app displays coffee shop locations in specified loc

null 0 Oct 31, 2021