Android development experience (GO)

Source: Internet
Author: User
Tags call back

Preface: A long time ago, I heard that Android will fire, as a forward-looking understanding of it will be a good chance of transformation, javaweb is too mature saturated, now on the market all kinds of Android phones in the endless, online various Android video series like follow-up, Android suddenly became a hot topic, at the beginning is also out of personal interest to learn the very hi feeling very easy to get started, later work found a lot of problems are also very tricky, slowly in the tangled and painful to figure out some experience and rules!

1.android as a view layer, to achieve low coupling with the service layer, must use the WebService interface, there is no very perfect plug-in, have tried axis Android bag (also a interested person to do their own), after using the feeling very troublesome, In particular, the transmission of complex data types, but also a lot of bugs, but also to change others source code, undoubtedly increase the team's learning costs and development difficulties, helpless under their own, the Android use Apache httpclient send interactive request, define a good XML interface transfer data, Reception is also resolved with dom4j, Tested in 2.2 dom4j support is very good, 2.1 less analytic usage is not supported, but most can use, speaking of which everyone may understand, yes, the backend is using the servlet mechanism, and then using Java reflection to describe the dynamic invocation of the specified spring services and methods according to the XML file, which is sufficient and can be fully To make more flexible extensions.

2.httpclient is really a good thing, but as a stateless access protocol, HTTP can not save user session information, so opened the source of the axis to find it originally when the user's first access information saved to a specific file, and then according to the heartbeat mechanism, timed calibration, enlightened, So I saved the user's first access information in the database session table, and wrote a stored procedure, timed to the session logon time is more than 30 minutes from the current record to do the delete operation, the user every login to the session table to match, no record immediately time-out strong retreat, so that the convenience is much easier, Then every time the user accesses the system in the XML file with the system to its string number, that is, SessionID, only to call a complete session.

3.android system Drawing is a troublesome work, the beginning of our team to find all the drawing of the plug-ins, are worried about half, no way to find special satisfaction, either is the use of too much trouble, or can not find the effect we want to study very tired and no clue, asked some of the original J2ME old programmers, They suggest that if it is not a professional game, statistical chart of these or with the help of the server to do a more appropriate, so we abandoned all the Android side drawing plug-in, using Jfreechart on the service side of the picture, image HTTP streaming to the mobile display, Of course, because the 2.1 system does not support flash, it is not considered to be more beautiful, the chart is very intuitive and clear.

4.UI is a difficult point, and in order to adapt to different resolutions, before using PX unit is very problematic, and then changed the dip positioning, good many, after a large area using tab style, unified style, a lot of difficulties, such as to tabhost add style dynamic change effect, button transparent, The ListView to the horizontal line plus arrows plus dynamic shiny plus flip page, as well as gesture swipe, a variety of widget effects and animation cutting screen, in order to avoid detours, we decompile the QQ, Fetion, 58, market, air tickets, ink weather and other mainstream Android layout and landscaping usage, Absorbing a lot of useful experience, but still feel the layout is difficult to do, the artist can not directly intervene and the 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 that only done to know the bitterness, one to do a good breakpoint continuation, two to do a good job of initializing the database, three to do the signature, four to do a good version of the algorithm and can display dynamic progress bar and percentage, the breakpoint continued to do, but the database initialization trouble point, Our approach is to copy the SQLite library files directly from raw to the SD card , and set the SQLite read library path to it, it feels so good, the signature is not known at the beginning, each time the overwrite prompts the installation is not completed, and then understand in order to ensure the uniqueness of the application, It's like an ID card, and nothing else works, and Symbian's signature is not the same thing, the package apk must be guaranteed to cover the installation with each other under the same signature file!

6.webview can call back-end Java code, similar to Dwr function, but this function has been used very little, very unstable, compatibility to consider, since Android provides so many UI controls, it means that webview can not replace it, after all, the need to invoke the underlying services, WebView is good to use with caution.

7.android should also follow the MVC programming specifications, activity is only responsible for handling jumps, UI, and simple data validation work, business logic placed in the service class, SQLite operation a little encapsulation, do a similar Jdbcutil template class, to provide additions and deletions to search, Pagination and other methods, so DAO operation is perfect many, 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, through the writing program found that the programmer to do mobile phone development, basic qualities to perfect, especially in the collection, threading , abnormal, io,http these to be very thorough, otherwise a seemingly very simple function, may be written bug, even low efficiency, poor readability, basically their own back to see what they write, on the interface and abstract classes, including anonymous inner class to be perfect, familiar with the basic structure of class package , in time on their own completion of the function of the Code optimization and reconstruction, so that they and others read like poetry, clear and graceful, it is not as mature as the web framework, we all use SSH, are very normative to follow, according to the general picture can not see a personal foundation! I would like to say that want to do Android development programmer, pay special attention to the Java Foundation!

8. Map navigation is also a bright spot, now no matter what function will be used to map navigation, beer and skittles, users want to know where, at present, Baidu Google has launched the Android map interface, we are using ArcGIS, fortunately API is not much application 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 Android code The biggest tangle is the test to find bugs, the simulator is very slow, no matter where you modify, you have to recompile the deployment, ADT plug-ins often occur debug failure, want to speed up development, first of all, the Eclipse automatic compilation off, the simulator useless process killed, And then put some useless mobile phone effects off, modular development, so that the entire method to cut out to put in junit test, There is a call Youwave_android simulator, the use of very fast , if there is no real machine under the circumstances can use it to transition, Nothing can also download more Android software, learn how other people's system is how to do, at least to improve the UI aesthetic, someone proposed on the Linux platform development, if never used the best not to add to their own difficulty, really want to try to recommend the use of UBUNTU10 Chinese desktop version, Although the speed is not feel much faster, but it is a gradual exercise to improve their good chance, more than the pressure of the body!

10.  Some tips are quite practical, some ADB commands must be faster than using the ADT plugin , the new SDK upgrade package put it in the Platform-tools directory; the simulator has a shortcut key CTRL + F11 or keypad home; If your debug fails, try to kill the process in the DDMS deployment retry, if not yet only restart the emulator, if you suddenly find that Gen directory does not generate R.java files, then show Problems look at the project is not error, generally not the package path has a problem is the program internal layout file has errors, if still invalid, turn off eclipse to reopen it, sometimes ADT will appear such Bug;adt plugin and SDK upgrade package is version dependent, If you are using more than 8.0 ADT plug-ins, remember that the SDK upgrade package must be up-to-date, otherwise you will not find the ADB command error, do not be confused on the upgrade plug-in, the latest 10 plug-ins can only run on more than 3.5 eclipse, and it does not bring much surprise, just support the higher SDK version; Android The program itself is flawed, do not drill too deep and it is not going to go to the place on the other road around, as long as the simple and simple not trite, the program can be robust, and a few more Android developers forum Community under the source post for help, technology this thing, without him, only hand-cooked!

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.