简体   繁体   English

高效启动应用程序的最佳方法

[英]Best way to start an application efficiently

It's in the question, I would like to know what is the most efficient way to start an Android application that need : 问题在于,我想知道什么是启动需要的Android应用程序的最有效方法:

1- xml/json stream to be downloaded with WebServices (text, image url, dataq, ...) 1- xml / json流将通过WebServices下载(文本,图像url,dataq等)

2- Data saved in sqlite, and then loaded to be used in the application (data from 1-) 2-将数据保存在sqlite中,然后加载以在应用程序中使用(1-的数据)

3- Data saved in SharedPreference loaded to be used in the application too (some user inputs) 3-保存在SharedPreference中的数据也被加载以供应用程序使用(某些用户输入)

4- Images to be downloaded from url (urls from 1-) 4-要从网址下载的图片(网址为1-的图片)

What I need is a good way to start an application with all the constraints (data loading from webservice, sqlite insert/update, ...etc) but for the application to be launched the fastest possible and the data to be loaded the must efficiently. 我需要的是一种在所有约束条件下启动应用程序的好方法(从Web服务加载数据,sqlite插入/更新等),但是要使应用程序尽快启动,必须​​高效地加载数据。

I'd say that on pure speed this is the order; 我要说的是纯粹的速度。 SharedPref - SQLite - xml/json. SharedPref-SQLite-xml / json。

Making a network connection is always slower then doing something local on the machine itself. 与在计算机本身上进行本地操作相比,建立网络连接总是较慢。 Even if it wouldn't be in perfect conditions, you can not assure perfect mobile internet and server performance. 即使不是在完美的条件下,您也无法保证完美的移动互联网和服务器性能。 After that, you still have to parse it. 之后,您仍然必须解析它。

SharedPreferences aren't made for saving whole data structures, just for simple things as small settings which you want to hold on to for a while. 并不是为了保存整个数据结构而创建SharedPreferences,只是为了将一些简单的事情作为小的设置而保留一段时间。

What you want to do with your data is load it from the server once. 您要对数据进行的操作是从服务器加载一次。 Preferably without showing loading screens etc. Save this into a the SQLite database. 最好不显示加载屏幕等。将其保存到SQLite数据库中。 On the next start-up, you can (almost) instantly show the data from the database, and update from the webservice in the background to keep up to date. 在下次启动时,您可以(几乎)立即显示数据库中的数据,并在后台从Web服务进行更新以保持最新。

Good question ! 好问题 ! I'll answer with a list of awesome libs. 我将列出一系列很棒的库。 First you should definively have a look at AndroidAnnotations This will really simplify your work. 首先,您肯定要看一下AndroidAnnotations,这确实可以简化您的工作。 Don't be afraid of perfs on Annotations. 不要害怕在Annotations上的表现。 it's not reflexion but a compilation step. 这不是反思,而是编译步骤。 It really eases the use of shared preferences. 它确实简化了共享首选项的使用。 For http stuff , spring is pretty good and well integrated with android annotations. 对于http来说, spring很好,并且与android注释很好地集成在一起。 I never used xml in WS, But for json mapping , i use Jackson and it's pretty fast and flexible. 我从未在WS中使用过xml,但是对于json映射,我使用Jackson,它非常快速和灵活。 I think gson does the job well too. 我认为gson也做得很好。

For image loading, UIL is the most efficient and the most mature ( so, it was the case in July when i benchmarked, Picasso and Volley too). 对于图像加载,UIL是最有效和最成熟的(因此,在我进行基准测试时,7月份也是如此,毕加索和Volley也是这种情况)。

For now i have not found the ORM saint graal, but my advice is "Does you really need a database ?" 现在,我还没有找到ORM圣人,但我的建议是“您真的需要数据库吗?” if you got a doubt backoff. 如果您有怀疑的退缩。 if you need it, ormlite has some perfs problems. 如果需要,ormlite有一些性能问题。 In my next project ,I'll give a try to greenDao. 在我的下一个项目中,我将尝试greenDao。

Definitively use a CursorAdapter for ListView+ SQLite , instead of loading in Listview. 明确地将CursorAdapter用于ListView + SQLite,而不是在Listview中加载。 But be sure to not access the database intensively at the same time (WS writes). 但是请确保不要同时密集访问数据库(WS写)。

If you need to pass events like "Hey new data is available in database refresh", don't make boilerplate interfaces. 如果您需要传递“ Hey new data is available in database refresh”之类的事件,请不要创建样板接口。 Use an event bus this is awesome EventBus 使用事件总线,这真是太棒了

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

相关问题 在Android中有效删除SQL行的最佳方法 - Best way to efficiently delete SQL rows in Android 开始挥杆应用程序的最佳实践 - Best practice to start a swing application install4j:通过链接启动我的应用程序的最佳方法是什么? - install4j: What is the best way, to start my application over a link? 将此Java Swing应用程序转换为沙盒嵌入式(applet或Web Start)的最佳方法是什么? - What is the best way to turn this Java Swing application into a sandboxed embed-able (applet or Web Start)? 从j2ee应用程序启动异步Java进程的最佳方法是什么 - what is the best way to start a asynchronous java process from j2ee application 用Java Web Start程序创建客户机/服务器应用程序的最佳方法是什么? - What is the best way to create a client-server application with a Java Web Start program? 使线程从jbutton开始的最佳方法? - Best way to make a thread start from a jbutton? 什么是启动GrizzlyWebServer的最佳方式? - What's the best way to start a GrizzlyWebServer? 正确启动Java Swing桌面应用程序的方法 - Proper way to start Java Swing desktop application 哪个是从服务器更新应用程序的最佳方法? - which is the best way to update an application from a server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM