Absrtact: Text will describe the author's experience in ANDROID+J2EE system integration development, hoping to inspire.
A long time ago, I heard people say that Android will fire up later, as a forward-looking, understanding of it will be a good opportunity for transformation. Javaweb is too mature saturation, now on the market, a variety of Android phones, online, like a variety of Android video serials follow, Android has become a hot topic, just at the beginning is out of personal interest to learn very hi feel very easy to start with the look, Later in the work to find a lot of problems are also very difficult, slowly in the tangle and pain to figure out some experience and laws.
1. Android as the view layer, to implement low coupling with the service layer, you must use the WebService interface. There is no very perfect plugin, has tried axis's Android package (is also an interested person to do), after using the feeling very troublesome, especially the complex data type transmission, but also a lot of bugs, but also to change the source code, undoubtedly increase the team's learning costs and development difficulties, helpless under their own. The Android side uses Apache's httpclient to send the interactive request, the definition good XML interface transmits the data, receives is also uses DOM4J to parse, after tested in 2.2 dom4j support is very good, 2.1 less analytic usage does not support, but most can use, said that everybody may understand. Yes, the backend is a servlet mechanism, and using Java reflection to dynamically invoke the specified spring services and methods based on the XML file description is sufficient, and can be done in its own way with more flexible extensions.
2. HttpClient is really a good thing, but as a stateless access protocol, HTTP cannot save user session information. Then opened the axis of the source found it is the user's first access to information to save to a specific file, and then according to the heartbeat mechanism, timed to do the check, the light, so I put the user first access to information stored in the database session table, and wrote a stored procedure, Timing of the session to log the time distance of more than 30 minutes of the record to do the deletion, the user each login to the session table to match, no record instant timeout strong retreat. So, the convenience is much simpler, then the user each access system must be in the XML file with the system to its serial number, that is, SessionID, just call a complete session.
3. Android system Paint is a trouble to live, the initial period of our team looked at all the paint plug-ins, are more than half, there is no way to find particular satisfaction, or use too much trouble, or can not find the effect we want, research is very tired also have no clue. Asked some former J2ME old programmers, they suggested that if not professional to do the game, the statistical chart of these or the use of services to do more appropriate, so we abandoned all the Android end Paint Plug-ins, using Jfreechart in the service side, picture HTTP streaming to the mobile phone side display, Of course because the 2.1 system does not support Flash, also did not consider in doing more beautiful, the chart is very intuitive and clear.
4. The UI is a difficult point, and in order to adapt to different resolutions, the PX unit before the problem, and then changed the dip positioning, a lot of good, and then a large area using the tab style, unified style, a lot of difficulties, such as tabhost add style dynamic change effect, button transparent, ListView to the horizontal plus arrow and dynamic light and pull the page, as well as gestures slide, a variety of widget effects and animated cut screen. In order to save detours, we decompile the QQ, flying, 58, fair, air tickets, ink weather and all the mainstream Android layout and landscaping usage, absorbing a lot of useful experience, but still feel the layout is difficult to do, art can not directly intervene and simulator test is not to force, no way can only use the real machine test UI, Speed can be much faster.
5. Android Client update function, I believe only do know the bitterness, one must do a good job of the breakpoint, two to do the initialization of the database, three to do the signature, four to do a good version of the algorithm and can display dynamic progress bar and percentage. Breakpoint continued to do, but the database initialization trouble point, our approach is to SQLite library files directly from raw under the copy to the SD card, and set the SQLite read Library path to point to it, feel so good. Signature at the beginning do not know, each cover is prompted to install unfinished, and then understand in order to ensure the uniqueness of the application, it is like an identity card, and other useless, and Symbian signature is not the same thing, encapsulation apk must ensure that under the same signature file can cover each other installation.
6. WebView can call back-end Java code, similar to the DWR function, but this feature has been used very little, very unstable, compatibility to consider, Android since the provision of so many UI controls, it shows that webview can not replace it, after all, also need to invoke the underlying services, WebView is still good to use carefully.
7. Android should also follow the programming specifications of MVC, activity is only responsible for processing jumps, UI, and simple data validation, business logic placed in the service class, SQLite operation in a little package, to do a similar type of Jdbcutil template class, to provide additions and deletions to check, Paging and so on, so DAO operations are much better. I think as a Java programmer to do Android development, the biggest obstacle is not the framework is not in the Google SDK of those APIs, but the Java Foundation. By writing programs to discover, do mobile phone development programmer, the basic quality should be perfect, especially in the collection, thread, anomaly, io,http these should be very thorough, otherwise a seemingly very simple function, may write the bug is full of, even inefficient, readability is poor, basically oneself go back to look not understand oneself write is what, The writing of interfaces and abstract classes, including anonymous inner classes, should also be perfected.
Familiar with the basic structure of the package, in time to complete their own functions to do code optimization and refactoring, let oneself and others read like reading poetry, clear and beautiful, it is not as mature as the web framework, we all use SSH, there are norms to follow, according to the painting generally can not see the personal Foundation. What I want to say is that programmers who want to do Android development should pay special attention to the Java basics.
8. In addition, map navigation is also a bright spot, now no matter what function will be used to map navigation, eat, drink, users want to know where, the current Baidu Google has launched the Android map interface, we use ArcGIS, but the API is not many applications is also very simple, the official has a ready-made example, Let me this ArcGIS is two brushes of people can paste on the work.
9. Write the biggest tangle of Android code is the test to find bugs, the simulator is very slow, regardless of the changes where, to recompile the deployment, ADT Plug-ins often occur debug failure, want to accelerate development, first of all, will eclipse automatic compiler turn off, the simulator in the process of killing the useless, Then turn off some useless phone effects and modularize the development so that the whole method can be cut out and put into junit testing. There is a call Youwave_android simulator, the use of very fast, if there is no real machine in the case can use it to transition, nothing can also download more Android software, learn how others ' system is done, at least to improve the UI aesthetic. Some people propose to develop on the Linux platform, if never used the best not to add difficulty to themselves, really want to try to recommend the use of UBUNTU10 Chinese desktop version, although the speed is not feel faster how much, but it is a gradual exercise to improve their own good opportunity to do more than pressure body.
10. Some of the tips are very practical, some ADB commands must be faster than using the ADT plug-in, the new version of the SDK upgrade package put it in the Platform-tools directory; ; If you fail the debug, try to kill the process in the Ddms. Deployment retry, if not, only restart the simulator, if suddenly found under the Gen directory how does not generate R.java file, then show problems see if the project is not error, Generally not the package path has the problem is the program internal layout file error, if still invalid, turn off eclipse to reopen it, sometimes ADT will appear such a bug.
ADT Plug-ins and SDK upgrade packs are version dependent, if you are using more than 8.0 ADT Plug-ins, remember that the SDK upgrade package must be up-to-date, or you will be unable to find the ADB command error. Don't be at a loss to upgrade the plugin, The latest 10 plug-ins can only run on more than 3.5 of eclipse, and it did not bring much surprise, just to support the higher SDK version, the Android program itself is flawed, do not drill too deep and its rivalry, not go past the place to think of other road around, as long as simple and simple not threadbare, the program function is robust; Android Developer Forum Community under the source code Post help, technology this thing, without him, only hand-cooked er.
Finally attached here is a true machine configuration installation instructions, I use the Charm 9, other brands should have a mobile phone, the benefits are not much said, their own look.
Android is hot, but I heard that the Linux community administrator will remove Google's Android source code and say it is not completely open source, there is a suspicion of exploiting the open source community, if so, then Android will lose a lot of developers trust and support, in short, not very good results, Sincerely hope that the next time Google Baidu to see is not a lot of copy paste the Hello World example, but the real developers share and transfer experience, so open source is the hard truth.