1 2 3 4 5 6 7See here, the first choice to get the application of the targetsdkversion, judge whether is less than build.version_codes. KitKat (API level 19) to set the malwaysexact variable to indicate whether the exact time pattern is used.
public static final Long window_exact = 0;
public static final Long window_heuristic =-1;
Private Long Legacyexactlength () {return
(malwaysexact?) window_exact:window_heuristic);
}
public void Set (int type, long triggeratmillis, pendingintent operation) {
Setimpl (type, Triggeratmillis, Legacyexactlength (), 0, operation, NULL);
1 2 3 4 5 6 7 8 9 10As you can see here, the set () method directly affects Setimpl () passing in different parameters, thus affecting the execution behavior of set (). Concrete implementation in the Alarmmanagerservice.java, here is not to delve down.
See here, found that the Android targetsdkversion is nothing special, the system used it is very direct, even very "rough." Just use the API below to get targetsdkversion to determine which behavior to perform:
1We can guess that if the Android system is upgraded and this kind of compatibility behavior changes, it typically saves both old and new logic, and uses the If-else method to determine which logic to perform. Sure enough, in the source code search, we will find a lot of similar getapplicationinfo (). targetsdkversion < buid.xxxx such code, compared to the vast number of Android source, these are relatively small. In principle, this can lead to a change in the compatibility problem is the less the better, so every time the new Android version, the Android developer site will list what changes have been made here, developers need to pay special attention to.
So when we modify the APK targetsdkversion behavior changes, we have to do a complete test.
To look at the relationship between the three attributes
Minsdkversion <= targetsdkversion <= compilesdkversion
Ideally, the relationship between the three should be more like this in a stable state:
Minsdkversion (lowest possible) <= Targetsdkversion = compilesdkversion (latest SDK) br> uses a lower minsdkversion to cover the largest population and uses the latest SDK to set target and compile to get the best results for the new version.