Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will xml attributes above min API cause crashes in Android?

Tags:

android

xml

Or will those attributes just be ignored on devices with lower API levels?

Why can't I just test this out myself by launching an emulator below the attributes min API? None of those emulators are working for me: https://code.google.com/p/android/issues/detail?id=195990

For example if I use android:fontFamily="@string/sans_serif" (min API of 16) attribute on an EditText and run the application on an API 15 device, will the app crash or the attribute be ignored?

like image 951
Adam Johns Avatar asked Mar 14 '23 00:03

Adam Johns


1 Answers

it will just get ignored .. you can double check with a quick genymotion emulator https://www.genymotion.com/#!/download

http://developer.android.com/training/basics/supporting-devices/platforms.html#version-codes

Note: When parsing XML resources, Android ignores XML attributes that aren’t supported by the current device. So you can safely use XML attributes that are only supported by newer versions without worrying about older versions breaking when they encounter that code. For example, if you set the targetSdkVersion="11", your app includes the ActionBar by default on Android 3.0 and higher. To then add menu items to the action bar, you need to set android:showAsAction="ifRoom" in your menu resource XML. It's safe to do this in a cross-version XML file, because the older versions of Android simply ignore the showAsAction attribute (that is, you do not need a separate version in res/menu-v11/).

like image 199
Blundell Avatar answered Mar 24 '23 03:03

Blundell