Android Development-Basic Concepts small Finishing (ii) for the interview of the small partners to prepare ~ ~

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/iwanghang/

I am participating in the CSDN 2016 blog Star selection, hope to get your valuable a vote ~
Http://blog.csdn.net/vote/candidate.html?username=iwanghang
Please vote for me, thank you ~ ~
If there is no CSDN account directly using the/qq/Weibo landing can vote ~ ~

31. Please describe the broadcastreceiver.

The broadcastreceiver is used to receive and process broadcast notifications (broadcast announcements). Most of the broadcasts are initiated by the system, such as geographical change, low power, incoming SMS, etc. The program can also play a broadcast. The program can have any number of broadcast receivers to respond to the notifications it feels important. Broadcast receiver can notify users in a variety of ways: Start activity, use Notificationmanager, turn on background lights, vibrate devices, play sound, etc., most typically in the status bar display an icon, This allows the user to click on it to open the notification content. Usually one of our applications or the system itself in certain events (low battery, call SMS) to temporarily broadcast a intent out, we use to register a broadcastreceiver to listen to these intent and get the data in intent.


32. How to register and use Broadcastreceiverin manifest and code.

Register in Android Manifest
<receiver android:= "" Name= "" Receiver1 "" >
<intent-filter>
< action in the!----and intent--->
<actionandroid:name= "Com.forrest.action.mybroadcast"/">
</actionandroid:></intent-filter>
</receiver>
1, Intentfilter filter = new Intentfilter ("Com.forrest.action.mybroadcast");//and the intent action corresponding to the broadcast;
2, Mybroadcastreceiver br= new Mybroadcastreceiver ();
3, Registerreceiver (BR, filter);

33. Please describe how the next contentprovider is to achieve data sharing.

A program can completely expose its own data by implementing a content provider abstraction interface, and content provider exposes its own data in a way similar to a table in a database. Content provider stores and retrieves data, which allows all applications to access, which is the only way to share data between applications.
To make your application's data public, there are 2 ways to create a data own content provider or add your data to an existing content provider, provided that there is the same data type and that there is write content Provider permissions, Android provides content resolverr, and external programs can access the content provider data provided through the content resolver interface.

34. Please describe how the data is stored in Android.

Android provides a way to store data in 5 in the following ways:
1, using shared preferences storage data, used to store data in key-value,pairs format, it is a lightweight key-value storage mechanism, can only store basic data types.
2, the use of files to store data, through FileInputStream and FileOutputStream to operate the file. In Android, files are private to an application, and one application cannot read or write files from other applications.
3, using the SQLite database to store data, Android provides a standard database, support SQL statements.
4. Using content provider to store data is a bridge between all applications for data storage and retrieval, and it is the role of data sharing between applications. It is a special type of storage data that provides a standard set of interfaces for obtaining data and manipulating data. The system also provides several common content Provider such as audio, video, image, and personal information. If you want to expose your own private data, you can create your own content provider class, or add the data to the content provider for sharing when you have permission to control writes to that data. External access accesses and operates these exposed data through the content resolver.
5. Using the network to store data

35. Please describe the five types of layouts commonly used in Android.

The most commonly used layout methods are absolute layout, Relative layout, Linear layout, framelayout, Tablelayout. Linear layout and relative layout are the most common ways in which they can be laid out in an XML configuration file or in code.
1, Frame layout is the simplest way to lay out the controls can only be listed to the upper left corner, the control will overlap, can not be complex layout.
2, Linear layout can be set by the Orientation property of the linear arrangement of the direction is vertical or vertical, each row or column has only one element, can be complex layout.
3. Absolute layout allows child elements to specify accurate X-and y-coordinate values and display them on the screen. Absolute layout does not have a page border, allowing elements to overlap each other. It is an absolute coordinate, so it is not advocated in practice.
4. Relative layout allows child elements to establish their position relative to other elements or parent elements (by ID). As a result, you can arrange two elements in the form of Right-aligned, or up or down, or centered on the screen. Elements are arranged sequentially, so if the first element is in the center of the screen, then the other elements relative to the element are arranged in the relative position of the center of the screen. This is relative to the absolute layout, the use of relative coordinates, so in practice is more commonly used.
5. Table layout assigns the position of the child element to the row or column. A table layout consists of a number of table row, and each table row defines a row. The Table layout container does not display the row, column, or cell edge boxes. Each row has 0 or more cells, similar to the table in HTML. It is often used in practice.

36. What is the difference between padding and margin in the UI?

Padding is the margin of the control's content relative to the edge of the control, and margin is the margin of the control's edge relative to the other controls.

Some limitations of the 37.android itself, such as the APK packet size limit, the time limit when reading large files.

APK package size limit is not good to say, some apk is 100M, or can be installed on the phone. The average apk size is around 5~10m. The time to read large files should be within the main thread, with a time limit of about 5 seconds.

How does 38.ListView improve its efficiency?

1, use page load, do not load all the data at once.
2, Reuse Convertview. In Getitemview, determine if the Converview is empty, and if it is not empty, it can be reused.
3. Load images asynchronously. If the item contains Webimage, it is best to load asynchronously.
4. When sliding quickly, the picture is not displayed. When the Quick Slide list (scroll_state_fling), the picture in item or the view that needs to consume resources, can not be displayed, but in the other two states (Scroll_state_idle and Scroll_state_touch_ SCROLL), the view is displayed.


What is the difference between a 39.Android program and a Java program?

1, the implementation of the entry point, Android based on the Mainfest.xml configuration file Intent-filter,java based on the main
2. Ui,android based on Activity,java frame
3, Android based configuration file, Java is not.
4, Android based on component Activity,service,broadcast Receiver,content Provider,java not.

40. Talk about the understanding of the Android NDK.

The Android NDK is a set of tools that allow Android app developers to embed native machine code compiled from C, c + + source code into their respective application packages.
1. The NDK is a collection of tools.
The NDK provides a range of tools to help developers quickly develop C (or C + +) dynamic libraries and automatically package so and Java applications together as APK. These tools are great for developers to help with.
The NDK integrates the cross-editor and provides the corresponding MK file isolation CPU, platform, API and other differences, developers simply need to modify the Mk file ("Those files need to compile", "compile feature requirements", etc.), you can create a so. The NDK can automatically package so and Java applications together, greatly reducing the developer's packaging effort.
2. The NDK provides a stable, functionally limited API header file declaration. These APIs support a very limited number of features, including: C standard library (LIBC), Standard math Library (LIBM), compression library (LIBZ), log Library (Liblog).

41. Talk about the advantages and disadvantages of Android.

Advantages:
1, Android is open source, the market share is big.
2, Android can have a wealth of hardware choices.
3, Android is a Linux platform based open-source operating system, thus avoiding the patent barrier, is a completely free only mobile platform.
4. Because Android is developed by Google, it can be seamlessly combined with Google Apps.
Disadvantages:
1, security and privacy. Mobile phones are closely linked to the Internet, and personal privacy is hard to keep.

What happens to the GC in a 42.Android system when there is a memory leak?

The main reason for memory leaks is that you previously applied for memory space and forgot to release it. If a reference to a useless object exists in the program, those objects will reside in memory and consume memory because the garbage collector GC cannot verify that the objects are no longer needed. If there is a reference to the object, the object is defined as a "valid activity" and is not freed. To make sure that the object's memory will be recycled, we need to confirm that the object is no longer in use. The typical practice is to either set the object data member to null or remove the object from the collection. A memory leak is caused when the following conditions occur:
1. The cursor of the database is not closed.
2. When constructing adapter, the cache Contentview is not used.
3, when the bitmap object is not used, use recycle () to free memory.
4. The life cycle of the object in activity is greater than activity.
Debugging method: Ddms==>heapsize==>dataobject==>[totalsize]

How the view in the 43.Android UI refreshes.

There are many ways to update view in Android, so you need to distinguish between different applications when you use them. To distinguish between: multithreading and double buffering.
1. Do not use multithreading and double buffering
This is the simplest scenario, and it is generally only desirable for the view to redraw the UI when changes occur. You only need to explicitly invoke the Invalidate () method in the View object in the activity. The OnDraw () method of the view is automatically called.
2. Use multithreading and do not use double buffering
In this case, the new thread needs to be opened, and the newly opened thread will not have access to the View object. Forced access will be error: android.view.viewroot$ calledfromwrongthreadexception:only theoriginal thread that created a view hierarchy can touch its views.
At this point you need to create a subclass that inherits the Android.os.handler and override the Handlemessage method. Android.os.Handle is capable of sending and processing messages, you need to emit a message in the activity that updates the UI, and then your handler (you can use anonymous inner classes) to process the message (because the anonymous inner class can access the parent class variable, You can directly invoke the invalidate () method in the View object. That is, you create and send a message in a new thread, and then capture and process the message in the main threads.
3. Use multithreading and double buffering
Android's Surfaceview is a subclass of view, and she also implements double buffering. You can define a subclass of her and implement the Surfaceholder.callback interface. Because of the Surfaceholder.callback interface, the new thread will not android.os.Handler help. The Lockcanvas () method in Surfaceholder can lock the canvas and call Unlockcanvasand post unlock after the new image is drawn.

44. Understanding of Android virtual machine, including memory management mechanism garbage collection mechanism.

(no suitable answer found)

45.Framework working methods and principles, how the activity generates a view, what the mechanism is.

(no suitable answer found)









Reprint Please specify source: http://blog.csdn.net/iwanghang/



Welcome to mobile development enthusiasts to communicate
Shenyang or neighboring cities companies interested in developing Android, please contact me
Contact information

: Iwanghang
qq:413711276
Email: [Email protected]


Android Development-Basic Concepts small Finishing (ii) for the interview of the small partners to prepare ~ ~

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.