Experience in integrated development of Android + J2EE systems

Source: Internet
Author: User
Tags call back
Source: csdn blog published on reading: 5243 recommendations: 5 original article link [favorites] Abstract: the text will show the author's experience in integrated development of Android + J2EE, and hope to be inspired.

A long time ago, I heard people say that android will get angry in the future. As a forward-looking person, it will be a good opportunity for transformation to understand it. Javaweb is too mature and saturated. Now there are endless Android mobile phones on the market, and various online Android video series follow up, Android has become a hot topic at once, at the beginning, I learned from my personal interests that it was very easy to get started. Later I found many problems at work and it was very difficult, I learned some experiences and patterns from the tangle and pain!

1. Android, as the view layer, must use the WebService interface to achieve low coupling with the service layer. Currently, there are no well-developed plug-ins. I have tried axis's Android package (which is also made by an interested party). After using it, I feel very troublesome, especially the transmission of complex data types, there are also a lot of bugs, and we need to change other people's source code, which will undoubtedly increase the learning cost and Development difficulty of the team, but we did it by ourselves. Android uses Apache's httpclient to send interactive requests, defines the XML interface for data transmission, and receives data through dom4j resolution. According to tests, dom4j supports a good performance, but does not support less than 2.2 of parsing usage, but most of them can be used. You may understand this. Yes, the backend uses the servlet mechanism and uses Java reflection to dynamically call the specified spring service and method based on the description of the XML file. This is enough, in addition, you can make more flexible extensions in your own way.

2. httpclient is really a good thing, but as a stateless access protocol, HTTP cannot save user session information. So I opened the source code of axis and found that it was originally used to save the user's first access information to a specific file. Then, according to the heartbeat mechanism, I checked the information regularly, therefore, I saved the user's first access information in the database session table and wrote a stored procedure to delete records whose Logon Time in the session exceeds 30 minutes from the current time, the user logs on to the session table every time and does not have a record. In this way, it is much more convenient. Every time you access the system, you have to carry the serial number, sessionid, that is, the system gives it to the XML file. This is called a complete session.

3. drawing in the Android system is a troublesome task. In the early stage, our team searched for all the drawing plug-ins, but they were not satisfied with the problem, or they were too troublesome to use, either we cannot find the desired effect, and the study is very tired. I asked some old programmers who had previously worked as well as j2's. They suggested that if they were not specialized in playing games, it would be more appropriate to use the server for statistical charts. So we abandoned all the painting extensions on Android, the jfreechart is used to draw images on the server, and the HTTP images are displayed on the mobile phone. Of course, because the 2.1 system does not support flash, you are not considering making the images more beautiful. The charts are intuitive and clear.

4. UI is a difficult issue, and in order to adapt to different resolutions, it was very difficult to use PX units before. Later, we changed the dip positioning and improved a lot. After that, we used the tab style in a large area and unified the style, which had many difficulties, for example, you can add a style to the tabhost to dynamically change the effect. The buttons are transparent. The listview uses a horizontal line and an arrow to add a dynamic shiny display and drop-down pages, as well as gesture sliding, various widget effects and animation screen cutting. In order to avoid detours, We decompiled all mainstream Android la S and beautifying usage such as QQ, Feixin, 58, Yuji, plane ticket, and moji.com, and learned a lot of useful experience, however, I still feel that the layout is very difficult. The artist cannot directly intervene and the simulator test is not very powerful. I can't just use a real machine to test the UI, and the speed is much faster.

5. the android client updates the feature. I believe that only those who have done so will be aware of the bitterness. First, we must do a good job of resumable data transfer, second, do a good job of database initialization, and third, do a good job of signature, 4. Do a good job of version verification algorithms and display the dynamic progress bar and percentage. Resumable data transfer is good, but database Initialization is troublesome. Our practice is to copy the SQLite library file directly from raw to the SD card, and set the SQLite library reading path to point to it, it feels better. I didn't know the signature at the beginning. I was prompted that the installation was not completed every time I covered it. Later I realized that in order to ensure the uniqueness of the application, it was like an ID card. Other signatures were not the same as the signature of Saipan, APK encapsulation must be in the same signature file to overwrite and install each other!

6. webview can call back-end Java code, similar to the DWR function. However, this function has been rarely used and is unstable. Compatibility considerations should be taken into consideration. Since Android provides so many UI controls, it means that webview cannot replace it. After all, you still need to call the underlying service, and webview should be used with caution.

7. android should also follow the MVC programming specifications. activity is only responsible for jump, UI, and simple data verification. business logic is placed in the service class, And SQLite operations are slightly encapsulated, create a template class similar to jdbcutil, and provide methods such as adding, deleting, modifying, and querying pages, which improves DaO operations. I want to switch to Android development as a Java programmer. The biggest obstacle is that the framework is not the APIs in Google SDK, but the Java Foundation. By writing programs, it is found that the basic quality of Mobile Phone development programmers should be excellent, especially in collections, threads, exceptions, Io, and HTTP. Otherwise, a seemingly simple function will be required, there may be hundreds of bugs to be written, even with low efficiency and poor readability. Basically, I can't understand what I wrote in the back. For interfaces and abstract classes, the writing of anonymous internal classes should also be refined.

Familiar with the basic structure of the class package, and promptly optimize and reconstruct the code for the functions you have completed, so that you and others can read them as if they were reading poetry, which is clear and beautiful, it is not as mature as the Web framework. We all use SSH, and there are many standards to follow. I don't know my skills in painting! I want to talk about programmers who want to develop Android. Pay special attention to the Java basics!

8. in addition, map navigation is also a bright spot. Now, no matter what features you do, you will use map navigation, have fun, and want to know where you are. Baidu Google has released the android map interface, we use ArcGIS. Fortunately, there are not many applications in the API, and there are ready-made examples on the official website. This makes it possible for me to turn off ArcGIS with two brushes.

9. the biggest tangle of writing Android code is testing and finding bugs. The simulator is very slow. No matter where it is modified, re-compile and deploy it. The ADT plug-in often experiences debugging failures and wants to accelerate development, first, we should turn off eclipse automatic compilation, kill useless processes in the simulator, and then turn off some useless mobile phone special effects for modular development, this facilitates the entire method body to be split into JUnit for testing. There is a youwave_android simulator, which is very fast to use. If there is no real machine, you can use it for the Transition. You can also download more Android software if it's okay, learning how other people's systems are done can at least improve the UI aesthetics. Someone suggested developing it on the Linux platform. If you have never used it before, it is best not to make it difficult for yourself. I really want to recommend the ubuntu10 Chinese desktop edition. Although the speed is not much faster, however, it is a good opportunity to gradually improve your skills!

10. some tips are quite practical, and some ADB commands must be faster than using the ADT plug-in. The new SDK upgrade package puts it under the platform-tools directory; the keyboard shortcut Ctrl + F11 or keypad home is available for horizontal and vertical screen switching. If your debug fails, try to kill the process in ddms and try again. If not, restart the simulator; if you suddenly find that the R. if the Java file is ready, show problems to check whether there is an error in the project. Generally, it is not because the package path is faulty or the internal layout file of the program is incorrect. If it is still invalid, close eclipse and re-open it, sometimes the ADT will have such a bug.

The ADT plug-in and SDK upgrade packages depend on the version. If you use more than 8.0 ADT plug-ins, remember to use the latest SDK upgrade package. Otherwise, the ADB command cannot be found. Do not upgrade the plug-in. The latest 10 plug-ins can only run on Eclipse 3.5 or above, and it does not bring many surprises, but only supports higher SDK versions; android programs are also flawed. Do not go too deep to compete with them. If you cannot go anywhere, you may want to go around the road. As long as you are simple, simple, and unconventional, the program functions are robust; in addition, I have to add a few more Android developer forums to post source code for help. I have no technical skills!

The installation instructions on the real machine configuration are attached here. I use charm 9, and other brands of mobile phones should also have it. The advantages are not much to mention. Let's just look at it!

Although Android is very popular at present, I heard that the Linux community administrator has deleted the Google Android source code and said it is not completely open-source, and there is a suspicion of using the open-source community. If so, therefore, Android will lose the trust and support of many developers. In short, it is not a good result. I sincerely hope that the next time Google Baidu sees not a lot of Hello world examples pasted by copy, it is actually the experience shared and transferred between developers, so open source is the final truth!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.