Novice development Android Easy to appear error (constantly updated in ... )

Source: Internet
Author: User

Started to develop Android apps because it was always Java development and learning was easier.

Keep track of some of the minor issues that arise during your own development:

    • static variables

in the development, because of habitual problems, often some commonly used data (such as user information, etc.) static save, and later tested, whether in the application or in the activity, as long as the initialization of the static variable activity is destroyed, The initialized variables are randomly destroyed according to the system's garbage collection mechanism (see http://blog.csdn.net/ctcwri/article/details/8858414for details). , so you should use some other methods to save the data, such as singleton mode.

    • Findviewbyid NULL exception

When using multiple layout in an activity, the problem of Findviewbyid empty exceptions is also very error prone, since many times the view object is dynamically injected, so use View.findviewbyid when you use it.

    • The method of data docking in general-purpose activity

In development, it is common to define some general activity to deal with the processing logic of each module, such as defining WebView and so on, do not need to define an activity every time, use common to deal with, and in the process of data transmission, The previous activity should use Intent.putextra to pass parameters and use bundle extras = Getintent () in general activity. Getextras (); To obtain, when acquired, Should be added to Judge Extras.containskey ("key") to proceed, at the beginning, I also habitually use extras.getstring ("key") ==null| | Extras.getstring ("key") = = "" Way to judge, the result is a heap of errors.

    • customizing session issues in WebView

Custom WebView often in the Web page when the server side session loss problem, need to manually manage the WebView session to maintain synchronization with the server, otherwise, each access to the server, it is possible to create a new session.

Novice development Android Easy to appear error (constantly updated in ... )

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.