简体   繁体   English

Android支持库,最合适的使用方法是什么?

[英]Android support library, what is the most appropiate way of using it?

The support libraries allow us to use newer features even when using older versions of android, but I've noticed that they also work on newer versions. 支持库使我们即使在使用旧版本的android时也可以使用较新的功能,但是我注意到它们也可以在较新的版本上使用。

  • Are we expected to detect the version and choose to use the support library version of a class only if the application is made to run in an older version? 仅当应用程序在较旧版本中运行时,我们才期望检测该版本并选择使用类的支持库版本吗?

  • Or is it appropiate to simply use the support library version of a class even in cases where the regular version would be available? 还是仅在可用常规版本的情况下,仅使用类的支持库版本是否合适?

Right now I'm thinking the second option would be better as it would make the application simpler to read and understand, with less special cases. 现在,我认为第二种选择会更好,因为这会使应用程序更易于阅读和理解,并且特殊情况较少。 However are there any other pros and cons to consider? 但是,还有其他优点和缺点要考虑吗?

Is there a third option? 还有第三种选择吗?

We have both advantages and disadvantages on using Support library classes than Android Framework classes. 与Android Framework类相比,使用支持库类既有优点也有缺点。

Advantages : 好处 :

  • It is updated much often. 它经常更新。 If any issue is found, it can be fixed on next release of support library. 如果发现任何问题,可以在下一版本的支持库中对其进行修复。 For framework , google will have to release another version of Android. 对于framework,谷歌将不得不发布另一个版本的Android。
  • New APIs can be used on previous versions easily. 新的API可以轻松地用于以前的版本。

Disadvantages : 缺点:

  • Of course, APK size will increase. 当然,APK大小会增加。
  • "Which" support library to use is always a tedious task. 使用“哪个”支持库始终是一项繁琐的任务。

So, I will prefer option 2 所以,我会选择选项2

Or is it appropiate to simply use the support library version of a class even in cases where the regular version would be available 或者即使在常规版本可用的情况下,仅使用类的支持库版本也是合适的

Also, If any new version is available , it is notified on Android Studio. 另外,如果有任何新版本可用,则会在Android Studio上通知它。 We don't have to check manually if any update is available. 我们不必手动检查是否有可用的更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM