0
votes

I have small app. It has method that has been added in 26 API level.

...
getMaxNumPictureInPictureActions();
...

When i run it on device that has 24 API level, the app crashes. It's ok. Then i deleted that method and tried to use constant which has been added in 26 API level as well.

...
String s = Manifest.permission.BIND_AUTOFILL_SERVICE;
...

For some reason, after reading this line, the app doesn't crash.

Why it doesn't happen? 24 level doesn't have that constant and that's why this app must crash, mustn't it ?

Constants are compiled into the code as their value. Methods that are part of the SDK are supposed to be implemented on-device so it doesn't get compiled into the APK. - Corey Ogburn
Note that just because it doesn't crash, doesn't mean it'll do what you want it to do. If that constant means something else in an older API, you've probably introduced a bug. - Corey Ogburn