西虹市网

标题: 聊一聊:开发Android App的建议 [打印本页]

作者: guozhiwei    时间: 2024-1-21 19:33
标题: 聊一聊:开发Android App的建议

  影响产品效率的每个问题(例如功耗或内存使用)都会影响应用程序的成功。 这就是为什么在开发过程中确保优化,平稳运行以及Android系统没有问题的必要性。汨罗评测之家http://zx12123.com的相关问题可以到网站了解下,我们是业内领域专业的平台,您如果有需要可以咨询,相信可以帮到您,值得您的信赖!

  首先,您需要减少APP的运行时间

  如何有效地使用线程

  取消后台某些线程的操作

  我们知道应用程序执行的所有操作都默认在主线程(用户界面的线程)中执行,因此应用程序的响应速度将受到影响。 这可能导致程序崩溃,甚至系统错误。

  要加快响应速度,必须将网络查询,数据库操作或复杂计算从主线程移动到单独的线程。 最有效的方法。 您可以使用IntentService创建后台操作。

  但是在使用IntentService时需要了解一些限制:

  此类不会将信息传递给用户界面。

  一次只能处理一个请求;

  每个流程请求流程都不能被中断。

  - 初始化线程中的查询操作

  当在后台处理查询操作时,表示数据不是即时的,但是可以使用CursorLoader工具来加速交互,所以你的 活动与用户之间的互动不会受到影响。

  使用此工具后,您的APP将启动ContentProvider查询单独后台线程,并在查询完成后,将结果返回给调用请求。

  - 优化设备电池的使用寿命

  如果您的APP消耗太多电量,用户卸载您的APP就不足为奇了。 这就是为什么你应该尝试在使用APP时减少电池消耗。 例如,避免在更新数据时唤醒程序,并将文本数据转换为非JIT正则表达式操作。

  - 优化网络

  如果您没有网络连接,请让您的应用程序忽略网络操作,并仅在有网络连接且没有漫游时更新数据。

  选择兼容的数据格式,将包含文本数据和二进制数据的所有请求转换为二进制数据格式请求。 必须使用有效的转换工具。

  我建议您获得更快的用户体验,因此您需要避免重复访问服务器。

  GZIP库是压缩文本数据以有效使用CPU资源的好工具。

  - 优化上游应用程序的工作

  为防止潜在错误导致能耗,请指定超时时间。

  如果可以,则使用粗定位网络而不是GPS.Le比较GPS要求1毫安(25 * S140毫安),而一般网络仅使用0.1毫安(2秒* 180 MA)。

  在使用DisplayMetrics执行DPI任务时,请考虑在大量数学运算中使用低精度变量并缓存变量值。

  - 优化前台工作的应用

  重要的是要确保服务的生命周期是短暂的,因为每个过程需要2 MB的内存,当领先的程序需要内存将被重新启动。 我们必须保持使用的内存量不要太大

  你必须检查电池状态并进行批量更新前的网络,并且它也建议进行的重要替代操作之前要等待最佳的状态。

  在后台执行操作时,让用户看到电源的使用非常重要,例如更新周期。

  - 实现低内存使用用户界面

  如何找到显示布局的问题

  当一个独立的用户界面来创建布局,然后占用过多的内存,然后创建,所以会出现在用户界面的开发延迟的应用程序。

  您可以使用Lint工具,它解析APP的源代码以检查错误并优化控制结果。

  布局问题

  如果您的布局有问题,那么您需要简化其结构。 您可以将LinearLayout类型转换为RelativeLayout类型,这将减少演示文稿的层次结构。

  Suggestions for developing Android APP

  Every issue that affects product efficiency, such as power consumption or memory usage, can affect the success of your application. This is why it is necessary to ensure optimization, smooth operation and no problems with the Android system during the development process.

  First, you need to reduce the running time of the app.

  How to use threads effectivelyCancel the operation of some threads in the background

  We know that all operations performed by the application are executed by default in the main thread (thread of the user interface), so the response speed of the application will be affected.  This can lead to program crashes and even system errors.

  To speed up the response, network queries, database operations, or complex calculations must be moved from the main thread to a separate thread it’s the most effective way. You can use the IntentService to create background operations.

  But there are some limitations to be aware of when using the IntentService:

  This class does not pass information to the user interface.

  Only one request can be processed at a time.

  Each process request process cannot be interrupted.

  - Initialize the query operation in the thread

  When processing query operations in the background, the data is not immediate, but the CursorLoader tool can be used to speed up the interaction, so your interactions with the user are not affected.

  After using this tool, your app will start the ContentProvider query for a separate background thread and return the result to the call request after the query is completed.

  - Optimize the battery life of your device

  If your app consumes too much power, it’s no surprise that users uninstall your app.  This is why you should try to reduce battery consumption when using the app.  For example, avoid waking up the program when updating data and converting text data to non-JIT regular expression operations.

  - Optimized network

  If you don't have a network connection, ask your app to ignore network operations and update data only if there is a network connection and there is no roaming.

  Select a compatible data format to convert all requests containing text data and binary data into binary data format requests.  A valid conversion tool must be used.

  I recommend that you get a faster user experience, so you need to avoid having to access the server repeatedly.

  The GZIP library is a good tool for compressing text data to use CPU resources efficiently.

  - Optimize the work of upstream applications

  To prevent potential errors from causing energy consumption, specify a timeout period.

  If possible, a coarse positioning network is used instead of GPS. Le compares GPS requirements to 1 mA (25 * S140 mA), whereas a typical network uses only 0.1 mA (2 seconds * 180 MA).

  When performing DPI tasks with DisplayMetrics, consider using low-precision variables and caching variable values in a large number of mathematical operations.

  - Optimize the application of foreground work

  It's important to make sure that the service lifecycle is short-lived because each process requires 2 MB of memory, and when the leading program needs memory it will be restarted.  We must keep the amount of memory used too large

  You must check the battery status and make a network before the batch update, and it also recommends waiting for the best state before performing an important alternative.

  When performing operations in the background, it is important for users to see the use of power, such as the update cycle.

  - Implement low memory usage user interface

  How to find the problem with the display layout

  When a separate user interface is used to create the layout, then it takes up too much memory and then creates, so the application delays in the development of the user interface appear.

  You can use the Lint tool, which parses the source code of the app to check for errors and optimize control results.

  Layout problem

  If you have a problem with your layout, you need to simplify its structure. You can convert the LinearLayout type to a RelativeLayout type, which will reduce the hierarchy of the presentation.

  举报/反馈
作者: 钻石翘翘    时间: 2024-1-21 20:02
没事我就来看看,哈哈!
作者: 狄更斯    时间: 2024-1-21 20:19
过来看看的
作者: 天涯飞客    时间: 2024-1-21 20:41
真是 收益 匪浅
作者: 蝶の恋    时间: 2024-1-21 22:34
有竞争才有进步嘛
作者: 欲望!    时间: 2024-1-21 23:04
没事我就来看看,哈哈!
作者: 飞豹游侠    时间: 2024-1-21 23:28
找到好贴不容易,我顶你了,谢了




欢迎光临 西虹市网 (http://bbs.xihong021.cn/) Powered by Discuz! X3