Search code examples
androidpermissionslocation

Requesting app runtime permissions (Android)


I want to write a simple app which accesses the device's location. Only I will ever use the app. This is my first attempt in about 10 years to write an Android app, so it is the first time I've had to deal with runtime permissions.

My first question is, given that the app is solely for my use, is it possible to by-pass the need for runtime permission code?

Failing that, is there any simple example code that fills in the numerous gaps in the Android documentation?

To take one example: the doc includes the following:

when {
ContextCompat.checkSelfPermission(
        CONTEXT,
        Manifest.permission.REQUESTED_PERMISSION
        ) == PackageManager.PERMISSION_GRANTED -> {
    // You can use the API that requires the permission.
    performAction(...)

What does this mean? What "API that requires the permission"? What replaces the "..."?

There are several other similar gaps on the page.


Solution

  • You have mentioned that app is solely for your use then you don't have to write the code for the runtime permission you can skip it...

    How to do this... ?

    Step 1 : Just put all the permission you need inside the app manifest file and install the app

    Step 2 : Go to the app settings or app info in the phone and check for app permissions all the permission that you mentioned will be displayed there just toogle them manually

    That's it now write code to access the things which you supposed to write after getting permission