targetSdkVersion in android and compatibility with lower versions such as android 2.3 -


i read targetsdkversion in documentation , know targetsdkversion is. question when targetsdkversion 19 , if minsdkversion 8.. if app uses api 16 in parts of code, app run in android 2.3 ?

your app still run have check android version before using specific method. android studio prevent possible issue. if you're using api 16 method on api8, app crash. throw nosuchmethodexception or classnotfoundexception (depends). why have check version running prevent crash.

example

    if (android.os.build.version.sdk_int >= android.os.build.version_codes.jelly_bean){         view.setbackground(drawable);     } else {         view.setbackgrounddrawable(drawable);     } 

annotation

you can use annotation specify method run on specific version , above :

@targetapi(build.version_codes.jelly_bean) public static void setbackground(view view, drawable drawable){    view.setbackground(drawable); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -