Let's take a look at these knowledge points before looking for a job in Android development.

Source: Internet
Author: User
Tags finally block try catch java reference

Let's take a look at these knowledge points before looking for a job in Android development.
1. Listview list Efficiency Optimization

(1) reclaim views using convertview
(2) ViewHolder Mode
(3) asynchronously loading Images
(4) do not load images during fast sliding
(5) If the custom item contains an image, you need to process the image (reduce the memory occupied by the image)
A. compress the image boundary B. Use the option class to save the image size c. Avoid real-time image scaling. It is best to scale the image to the View Size in advance.
(6) Avoid using threads in the listview adapter as much as possible, because the main cause of Memory leakage is that the thread's lifecycle is uncontrollable.

2. Application Memory Optimization

(1) bitmap sets the image size (optimized memory overflow)
BitmapFactory. Option option = new BitmapFactory. Option ();
Option. inSampleSize = 2; // change the view width and height to the original 1/2
(2) destroy the bitmap object. You can use the recycle () method to retrieve the bitmap object by GC.
(3) Avoid using static member variables to reference instances that consume too much resources, such as context
(4) use the context of Application
(5) Close resources in time. For example, you need to close cursor in time when querying the database.
(6) Save frequently used images with soft references
(7) The thread is also an important cause of Memory leakage because the thread's lifecycle is uncontrollable. solution:
A. Change the internal class of the thread to the static internal class.
B. Use Weak references to save context references
(8) use. 9 images

3. What is ANR and how to avoid it?

ANR: Application Not Responding. In Android, the activity manager and window manager system services are responsible for monitoring Application responses. Android displays the ANR dialog box when the following conditions occur:
Response to input events (such as buttons and touch screen events) exceeds 5 seconds
The intentReceiver has not been executed for more than 10 seconds.

Android applications run completely in an independent thread (such as main ). This means that any operation that runs in the main thread requires a large amount of time will lead to ANR. At this time, your application has no chance to respond to input events and Intent broadcast ).

Therefore, any method running in the main thread should do as little work as possible. This is especially true for important methods in the activity lifecycle, such as onCreate () and onResume. Potential time-consuming operations, such as accessing networks and databases, or computing with high overhead, such as modifying the bitmap size, must be completed in a separate sub-thread (or using asynchronous requests, such as database operations ). However, this does not mean that your main Thread needs to enter the blocking status and waits for the sub-Thread to end-nor does it need to call the Therad. wait () or Thread. sleep () method. Instead, the main thread provides a Handler for the subthread so that the subthread can call it at the end of the process. Using this method involves your application, which ensures that your program responds well to the input and avoids the ANR generated because the input event is not processed for more than five seconds. This practice needs to be applied to all the threads that display the user interface, because they all face the same timeout issue.

4. What will cause Force Close? How to avoid it? Can I capture exceptions that cause them?

Generally, it is like a null pointer. You can check the logcat and resolve the error accordingly in the program.

5. What is the life cycle of the activity during screen switching?

1) when the android: configChanges of the Activity is not set, the split screen will re-call the life cycle of each Activity. The split screen will be executed once, and the split screen will be executed twice.
2) When setting the Activity's android: configChanges = "orientation", the screen will be re-called for each lifecycle, and the screen will be executed only once
3) when setting the android: configChanges = "orientation | keyboardHidden" of the Activity, the live cycle is not re-called and only the onConfigurationChanged method is executed.

6. Why does Android introduce the broadcast mechanism?

A: From the MVC perspective (in applications)
The four components of android are essentially designed to implement the MVC Architecture on mobile devices or embedded devices. They are sometimes interdependent and complementary, the broadcast mechanism can be introduced to facilitate information and data interaction between several components.
B: intercommunication between programs (for example, listening for system calls in your own applications)
C: efficiency (refer to the convenience of UDP broadcast protocol in LAN)
D: Design Pattern (an application of reverse control, similar to the listener pattern)

7. How to Prevent the apk from being decompiled in Android 8. multithreading combined with asynchronous callback. 9. Android species data storage methods and usage. 10. Several Methods for parsing XML files, as well as their advantages and disadvantages.

There are three main XML parsing Methods: SAX, DOM, and PULL. It is relatively easy to use Dom for general development on PC, but some performance-sensitive databases or mobile phones still use the SAX method. The SAX reading method is one-way and has advantages: it is not convenient to occupy memory space and parse attributes, but the disadvantage is that it is not convenient to process multiple branches. The DOM method loads the entire XML file into the memory. Here, the Android Development Network reminds you that this method can be used with XPath in search. If the data volume is not large, it is recommended to use it, while PULL is often used in j2s for better processing of nodes. Similar to the SAX method, PULL also saves much memory. We often use the KXML library for parsing in j2s. Android xml file parsing uses pull.

11. Use of the Android Message Processing Mechanism (Handler and logoff. 12. What if the Activity is recycled?

When the Activity is destroyed, the onSaveInstanceState (Bundle bundle) method is called. data can be stored and the Bundle object can be read when the Activity is onCreate (bundle Bundle) again.

13. Use of MVC. 14. Ask what design patterns and examples will be used in the project. 15. What are the four major Android components used? 16. How to monitor program crash information
Activity implement UncaughtExceptHandler Interface
17. Where is the anr log written?
The trace.txt file can be obtained through the command line
18. What is tomcat used?
Configure your computer as a server
19. What are the differences between dp and sp? 20. What is the principle of handler? 21. Can the sub-thread operate the UI?

Subthreads cannot directly operate the UI, but they can be operated using the following methods:
Activity. runOnUiThread ()
View. post ()
Handler
AsyncTask

22. mvc understanding, how to present it during development 23. Principles of used third-party frameworks 24. Understanding of http request results and returned values
200: Request successful 401: unauthenticated 403: Access prohibited 404: the specified resource cannot be found 500: Internal Server Error 504: gateway timeout
25. activity Lifecycle
OnCreate: Initialize data onStart: Page visibility, non-interactive onResume: Page visibility, interactive onPause: Page visibility, non-interactive, save data onStop: page invisible onDestory: Destroy page onRestart
26. How to exit an application

System. exit (0 );

27. How to open the browser in the android app and specify the type of intent
Intent intent = new Intent ("android. intent. action. view "); intent. setData (Uri. prase ("www.baidu.com"); intent. setClassName (); // specify the browser
28. What is the custom interface? 29. Difference between post and get

Get: used for request data. parameters are appended to the url. http itself has no limit on the request length, but some browsers and servers have limits on the length.
Post: used to generate data. The parameters are placed in the Request body, which is safer.

30. Differences between http and https 31. How to reclaim String objects 32. How to recycle garbage 33. Inter-thread Communication 34. Differences between HashMap and HashTable

HashMap was launched after JDK1.2 and allows null key values. It is more efficient than Hashtable due to non-thread security.

35. Subclass of Map

HashMap: unordered. It cannot be repeated. The key can be null.
HashTable: unordered, repeatable, and key cannot be null
TreeMap: ordered, not repeated
WeakHashMap: weak reference
IdentityHashMap: unordered, repeatable

36. Subclass of List 37. Differences between hashCode and equals
The comparison results of equals are the same, and the hashcode must be the same; The hashcode is the same, and the comparison results of equals are not necessarily the same.
38. How to override the equals Method

Person p1 = new Person ("tom", 21 );
Person p2 = new Person ("tom", 21 );
What is the result of p1.equals (p2?
The answer is false, because object. equals () compares the reference address by default. If you want p1.equals (p2) to return true, You need to override the equals method.

39. OOM Processing

Oom is a memory overflow, which usually occurs during image processing, so images can be compressed.
1. BitmapFactory. option boundary Compression
2. Bitmap. compress () changes Image Storage
3. When soft reference is used, resources can be released when the memory is insufficient to avoid memory overflow.

40. Which java reference types are available? What are their respective features?

Class, interface, array
I. Concepts
Basic Data Type: variable name points to a specific value
Reference data type: the variable name points to the memory address of the stored data object, that is, the variable name points to the hash value
2. In terms of memory construction
Basic Data Type: After the variable is declared, java will immediately allocate memory space to it.
Reference data type: it points to an object (specific value) in a special way (similar to a C pointer). Such variables do not allocate memory when declared, but only store a memory address.
Iii. Usage
Basic Data Type: You need to assign a specific value when using it, and use the "=" sign for determination.
Reference data type: You can assign null when using the equals method.

41. What are the advantages of java's exception handling mechanism?

First, when an error occurs, the program will not crash.
Second, when an error occurs, you can find the row where the error is located in a short time to save time.

42. Why does jvm cause memory leakage? 43. How to optimize the layout? Use Cases of include, merge, and viewStub

Labels can reuse layout files.
Tags play an important role in UI structure optimization. They can delete redundant levels and optimize the UI.
The biggest advantage of a tag is that it is loaded only when you need it. Using it does not affect the UI initialization performance.

44. What is the difference between String and StringBuffer?

The content of the StringBuffer object can be modified, but the String object cannot be modified once it is generated. The re-assignment is actually two objects.

45. What is the execution sequence of try-catch-finally code blocks?

Try {// executed code, which may be abnormal. Once an exception is found, the system immediately jumps to catch for execution. Otherwise, the content in the catch will not be executed}
Catch {// The code here will not be executed unless an exception occurs during code execution in try. Catch can have multiple or none}
Finally {// It will be executed in any situation, including the use of return in try catch. It can be understood that as long as a try or catch is executed, finally will be executed. Finally can be absent or there can be only one. If there is no catch block, finally block is required}

46. Does the array have the length () method? Does String have the length () method?

The array does not have the length () method. It has the length attribute. String has the length () method.

47. Can char store a Chinese character? Why?

Yes. A char in Java contains two bytes. java uses unicode and two bytes to represent a character. A number, English character, or Chinese character is a single character. However, when a number or English character is used, the first byte of the two bytes is 0, which is a waste of space. The reserved Chinese characters are full of 2 bytes.

48. What are the advantages and disadvantages of fragment? How can we understand the relationship between activity and fragment? 49. Differences between Thread and service

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.