650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/89/B9/wKioL1ga7nCD_DXjAARo5rh7YXo064.jpg "title=" 1.jpg " alt= "Wkiol1ga7ncd_dxjaaro5rh7yxo064.jpg"/>
We know that the Android application is mainly through the client-server way of data interaction, generally in the app development may be an interface corresponding to a display module, this design will make the client update is cumbersome. To solve this problem, the usual practice is to define the protocol with the server, design the display mode, in order to achieve the purpose of updating the UI in real time, adding or removing the display module without having to let the user update the APK manually, this method is most commonly used when doing activities or advertising. For example, with our superior Cloud Mobile, Android and iOS should use a unified interface to define our navigation bar, to plan and classify graphics for sub-page data under each navigation bar, and UI to give the front-end presentation. :
1
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/89/B9/wKioL1ga7oPhIeD4AAEEJSax2Zw540.jpg "title=" 2.jpg " alt= "Wkiol1ga7ophied4aaeejsax2zw540.jpg"/>
2
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/89/BB/wKiom1ga7ozCLdoSAAE4AgKNVfU055.jpg "style=" height : auto;vertical-align:middle;border:0px; "title=" 3.jpg "alt=" Wkiom1ga7ozcldosaae4agknvfu055.jpg "/>
3
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/89/BB/wKiom1ga7pnhne73AAFDA24vSJ0336.jpg "style=" height : auto;vertical-align:middle;border:0px; "title=" 4.jpg "alt=" Wkiom1ga7pnhne73aafda24vsj0336.jpg "/>
With the display mode design, the next step is to implement, for the client, HTTP communication Framework selection is very important, the current Andriod HTTP communication framework commonly used in the following four kinds:
· HttpClient:
Originating from Apache, it is more suitable for use in versions below Android2.2 and has been removed in Android6.0.
· HttpURLConnection :
Android standard implementation, support gzip compression, connection speed is much faster than httpclient, recommended to use.
· Volley :
2013 Google's third-party HTTP open-source framework, internally integrated with HttpClient and HttpURLConnection, has a thread pool inside to sort all the HTTP requests, In the network picture load uses the level three cache mechanism to make the network picture asynchronous loading, is suitable for the small quantity but the communication frequent place to use. This is the framework currently used by our end multiplicity mobile, but the lack of this framework is not enough to handle a service-oriented or abnormal situation. You can add error handling that may be returned on the server side based on the source code.
· okHttp :
2015 Google released the Okhttp, the function is very powerful, encapsulated the upload and download function of the file, image loading, processing a variety of server network errors, but the file size is 311k, some scenarios may be slightly bloated use.
Next we talk about memory analysis. The good code, we also need to do a memory check to see if there is a memory overflow or memory leak situation, here using the Mat tool provided by Google for visual analysis, to ensure that our memory is normal. First select our app in Ddms, click the Dump button, run the APK for a period of time or use monkey to automate the test for a while, click Dump again, Get the. hprof file, use the Hprof-conv command inside the ANDROIDSDK to convert. hprof files to Memoryanalyzer recognized files, then open the Mat tool, open a. hprof file, get the contents as shown in the memory analysis view.
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/89/B9/wKioL1ga7qnRAUJDAAETA0ni1FI985.jpg "style=" height : auto;vertical-align:middle;border:0px; "title=" 5.jpg "alt=" Wkiol1ga7qnraujdaaeta0ni1fi985.jpg "/>
Finally introduce the next APK file packaging, we are now most of the development with Android studio, packaging is also used gradle for channel classification packaging, after the configuration of the confusion files, gradle in the configuration of different channels, Channel number can be passed to the server to let the service side of different versions and different channel number analysis and control.
It is worth looking forward to, once installed on the mobile phone, you can view the app experience data anytime and anywhere.
This article is from the "excellent cloud dual-state Operations" blog, please be sure to keep this source http://uyunopss.blog.51cto.com/12240346/1868985
Excellent cloud Mobile Experts: Android Application HTTP Framework Selection