I have an application that behaves differently when compiled for API 18 and 19 (behaviour of repeating alarm).
The core behavior of AlarmManager
is not dependent upon how you compile the app. It is dependent upon the OS level of the device and, more importantly, your android:targetSdkVersion
.
The only difference in AlarmManager
based upon how you compile the app (i.e., your build target, Project > Properties > Android in Eclipse), is whether you have direct access to additional methods (e.g., setExact()
) on newer devices.
In such a case, will my app run the same on such a device, regardless of whether I compiled it for API 18 or 19?
This is impossible to answer in the abstract, even if we convert "compiled it" to "set the android:targetSdkVersion
". Some behavior changes will occur on newer devices regardless of android:targetSdkVersion
; some behavior changes will occur on newer devices only if your android:targetSdkVersion
is set to that API level or higher.
In the particular case of AlarmManager
, some of this is covered in the JavaDocs for the particular Build.VERSION_CODES
value of interest, such as KITKAT
:
AlarmManager.set becomes interpreted as an inexact value, to give the system more flexibility in scheduling alarms.
It is also echoed in the documentation for AlarmManager
itself, such as:
Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested.