Reputation: 582
I'm working on a project that has minSdkVersion set to 7. Of course target SDK is newer, 18.
I'd like to use in my project interface Application.ActivityLifecycleCallbacks
, but this is supported only from API level 14. I'm ok with not having that functionality for devices with older version of Android, still I'd like to use this interface to support newer devices with newer versions of API.
I'd be able to use Reflection or something similar if I were to only support a new class from newer API, but I don't know how to support a new interface. Can you point me somewhere? Thank you in advance.
Upvotes: 1
Views: 472
Reputation: 906
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void myCustomMethod(){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
// Your API level 14 code here
}
}
Upvotes: 4
Reputation: 3476
compose a wrapper that selects the calls to be made by Build SDK INT in some IF statements or use this third party lib:
https://github.com/BoD/android-activitylifecyclecallbacks-compat
Upvotes: 1