Key android knowledge and android knowledge

Source: Internet
Author: User

Key android knowledge and android knowledge

1. Relationship between handler and logoff, MessageQueue, and Message

Handler: a thread that processes time-consuming operations by the main thread (ui thread). It uses post message to send messages to the MessageQueue queue, uses handler to implement the handlerMessage method, and updates the ui of the main thread.

Loage: each loue corresponds to a MessageQueue, Which is loved before handler. prepare () initializes logoff and MessageQueue, and finally logoff. the loop method will distribute messages cyclically to the specified handler. In the api method, there is a msg.tar get. dispatchMessage (msg); this is the call between logoff and handler.


2. Advantages and Disadvantages of hander and AsyncTask

AsyncTask implementation principles and advantages and disadvantages

AsyncTask is a lightweight asynchronous class provided by android. It can inherit AsyncTask directly and implement asynchronous operations in the class,AndProvide interface feedback to the currentAsynchronous execution degree(UI progress update can be implemented through the interface), and finally the execution result is fed back to the main UI thread.

Advantages:

Simple and fast

Controllable Process

Disadvantages:

It becomes complicated when multiple asynchronous operations are used and Ui changes are required.


Handler asynchronous implementation principles and advantages and disadvantages

When Handler is implemented asynchronously, it involves four objects: Handler, logoff, Message, and Thread. the asynchronous process is that the main Thread starts the Thread (subthread) run and generate Message-Logoff to get the Message and pass it to HandlerHandler to get the Message in logoff one by one, and change the UI.

Advantages:

Clear structure and clear Function Definition

Simple and clear for multiple background tasks

Disadvantages:

In asynchronous processing of a single backend, there are too many codes and the structure is too complex (relative)



3. Several common storage methods in android

A. Content provider

1) ContentProvider provides a unified interface for data storage and reading.

2) using ContentProvider, applications can share data

3) Many of the android built-in data is in the ContentProvider format for developers to call (such as video, audio, image, Address Book, etc)

First in Androidmanifest. register the provider permission in xml, and then use getContentResolver () to obtain the contentResolver () object. You can add, delete, and change the application to the same database operation. The required parameters are uri and parameter values, generally, the Cursor obtains the attribute value by traversing the Cursor.

B. SharedPreferences

In fact, SharedPreferences processes a key-value pair ). SharedPreferences is often used to store lightweight data. use getSharedPreferences () to get the SharedPreferences object and then get the edit object used to put the value to the object to be modified. Finally, edit is required. commit () to store the modified object to a file, and finally save it as a file in the specified path of data/data

C. sqlite Storage

SQLite is a lightweight small database. Although it is relatively small, it has relatively complete functions, and some common basic functions of databases are also available, this database is widely used in embedded systems because it occupies a small amount of system resources.

You need to inherit SQLiteOpenHelper and then helper. getWritableDatabase () to obtain the SQLiteDatabase object. This object can be used to add, delete, modify, and query data and provide the CURD method in the form of key value.

D. io stream Storage

 

E. webview Network Storage

4. How do you optimize listview.

ViewHolder and convertview are used to optimize memory and reduce the number of view instantiation. When item1 is slid out of the screen, a new view instance of item1 is not required. In android, Recycler is provided) component, and viewHolder is a static class, the fastest way is to define a ViewHolder, set the tag of convetView to ViewHolder, and use it again when it is not empty.

4.1. listview image loading Optimization

1. The biggest secret of decodeStream is that it directly calls JNI> nativeDecodeAsset () to complete decode,
You no longer need to use createBitmap on the java layer, which saves the java Layer Space and sets the image compression ratio to reduce memory usage.

InputStream is = this. getResources (). openRawResource (R. drawable. pic1 );
BitmapFactory. Options options = new BitmapFactory. Options ();
Options. inJustDecodeBounds = false;
Options. inSampleSize = 10; // width, hight is set to the original 10-minute-one
Bitmap btp = BitmapFactory. decodeStream (is, null, options );,
2. Reclaim image Cache

If (! Bmp. isRecycle ()){
Bmp. recycle () // reclaim the memory occupied by the image
System. gc () // remind the system to recycle it in time
}



5. Refresh the view, as mentioned earlier

View can call the invalidate () and postInvalidate () Methods to refresh

6. IPC and principles


7. Multiple Android threads


8. Why do Android need to design four major components? the connection between them is not feasible without design (mainly to implement the MVC mode, but this is also the most difficult mode in java, few products can make this model very good [This Is What Technicolor's interviewer asked ])


9. service cycle and activity cycle. Let's talk about your understanding of Android internal applications, such as phone calls and contacts. There are a lot of things in the framework layer. If you are familiar with how Android works, it is very good whether you are doing application development or application framework layer development.



For android development, what java knowledge is important?

If you have some java basics, you can look at android directly. If you do not know how to look back, you can look back.
If you haven't touched java, but have a Development Foundation, you can look at the basic java syntax content, loops, arrays, inheritance, interfaces, and understand it.
In short, all languages have a common point. You will have a good grasp of others.
You said "not this professional", that is, you have never learned any programming language? It is not easy to do that.

What knowledge points do android users need to learn?

1. Java BASICS (syntax basics, collection frameworks, IO, and network programming, understanding awt, swing, and Java event mechanisms)
2. XML knowledge
3. Linxu knowledge
4. Android controls and services




Related Article

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.