android - 如何提高 Android 应用程序的整体性能?

标签 android performance optimization android-proguard

当我试图减少我的 Android 应用程序并对其进行优化时,我会寻找所有可能的方法来做到这一点。这是我发现的:

一个。 Android Developer Tips

  • Avoid Creating Unnecessary Objects
  • Prefer Static Over Virtual
  • Use Static Final For Constants
  • Avoid Internal Getters/Setters Use
  • Enhanced For Loop Syntax, etc.

B. https://software.intel.com/en-us/android/articles/5-ways-to-optimize-your-code-for-android-5.0-lollipop

  • Use local variables instead of public class fields when possible.
  • Use the final keyword to hint that a value is constant
  • Use the final keyword for class and method definitions, etc.

C.而不是使用 view.setOnClickListener(new View.OnClickListener...),使用 view.setOnClickListener(this),通过将监听器附加到 Activity 或 fragment 。

D. http://www.vogella.com/tutorials/AndroidApplicationOptimization/article.html

E. http://developer.sonymobile.com/2012/01/31/tips-for-reducing-apk-file-size/

  • Remove debug information.

F. http://hsc.com/Blog/Best-Practices-For-Memory-Optimization-on-Android-1

  • Use Optimized Datacontainers
  • Use Proguard And Zipalign

G. http://ernelljava.blogspot.se/2012/04/do-not-create-objects.html

  • Do not overuse String, use StringBuilder for working with String.

H. https://github.com/futurice/android-best-practices

是否有任何其他技巧可以帮助我优化我的应用程序?

最佳答案

检查以下几点以获得更好的编码和优化,

(-) 保持你的编码干净,并且是小部分,

(-) 不要写长的单个函数,把它分成小函数,

(-) 永远不要在主线程上调用任何网络功能,为此始终使用异步任务。

(-) 任何资源在使用完成后,迅速释放它,不要一直使用它,以避免出现死锁情况。

关于android - 如何提高 Android 应用程序的整体性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31911386/

相关文章:

javascript - 使用 jQuery 快速选择表格列

android - 这适用于所有屏幕尺寸吗?

android - 将图像存储在应用程序内存中的最佳方式是什么?

java - UDP 客户端向服务器发送数据,但没有收到响应

c++ - 如何测量一组特定线程的 CPU 时间?

performance - 关于Clojure的 `first`函数的性能

android - 未播放通知声音。权限拒绝

android - 如何为 guice 3.0 配置 ivy.xml 以使用 no aop jar?

linux - 如何测量进程的单独 CPU 核心使用率?

c# - 提高应用程序性能