Created
November 27, 2020 15:52
-
-
Save ayetolusamuel/cfe765433058a6d0de877b76d0065434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//runtime permission check for location | |
fun checkPermission(): Boolean{ | |
return ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED | |
} | |
//request permission | |
fun requestPermission(){ | |
ActivityCompat.requestPermissions(this, | |
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), | |
locationPermissionCode) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fun Context.deleteSharePreference(key: String) {
val settings: SharedPreferences = getDefaultSharedPreferences(this)
settings.edit().remove(key).apply()
}