'It is possible to compile with Api 23 (6.0) and to maintain the old permission system (install-time)?

I readed this in the official android blog:

Permission Changes With Marshmallow, permissions have moved from install-time to runtime. This is a mandatory change for SDK 23+, meaning it will affect all developers and all applications targeting Android 6.0.

So... it is possible to mantain the old permission system if you compile with Android 6.0 (api 23) but you target Android 4.4 (api 20)?

I mean doing this:

    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 20
    }

The requisites of my project for now are to maintain the old permission system and to target sdk version 20 (because I need to maintain the old notification system and if you target sdk version higher than 20 you must use the new notification system). So... can I compile with Api 23 and maintain old permission system if I target sdk version 20?



Solution 1:[1]

Yes the old permission system will be used (even on Android 6.0) if targetSdkVersion is set <23. However an user on Android 6.0 can later manually disable individual permissions from Settings. Although Android 6.0 will warn the user when they try to do that but they can revoke anyway.

Now the question is will your app crash after user revokes permission?

When we call a function that requires a permission user revoked on application with targetSdkVersion less than 23, no Exception will be thrown. Instead it will just simply do nothing. For the function that return value, it will return either null or 0 depends on the case. Although application would not be crashed from calling a function. It may still can crash from what that application does next with those returned value.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1