Ten Suggestions for Android programming

Source: Internet
Author: User

 

A: To become a real Android player, you must master and follow the following guidelines:
1) Learn laziness
Adon't reinvent the wheel (do not reinvent the wheel ).
Binventing the wheel ).
Cdon't reinvent the wheel (do not reinvent the wheel ).
"Wheel theory", that is, "Do not reinvent the wheel", is a saying in Western countries. The original saying is: Don't reinvent the wheel. "Don't reinvent the wheel" means that someone has actually done a job in an enterprise. All we need to do is find someone who has done it. In the software field, it refers to some projects or functions that others have already done. When we need them, we can use them directly instead of making them again.
2) proficient in Android architecture, MVC, common design patterns, and control reversal (IOC)
3) write code with high reusability, scalability, maintenance, and flexibility
4) Efficient Coding
5) learn at least one server-side Development Technology

What is JNI?

A: JNI is the abbreviation of Java Native interface. It is called locally in Java in Chinese. Java Native Interface (JNI) standards have become part of the Java platform since java1.1. It allows Java code to interact with code written in other languages. JNI was initially designed for locally compiled languages, especially C and C ++, but it does not prevent you from using other languages, as long as the call conventions are supported.

Using Java to interact with locally compiled code usually results in loss of platform portability. However, in some cases, this is acceptable or even necessary. For example, you can use old libraries to interact with hardware and operating systems, or to improve program performance. The JNI standard should at least ensure that local code can work under any Java Virtual Machine implementation.

What is the difference between Android and Linux?

A: Android is a software set dedicated to mobile devices, including an operating system, middleware, and some important applications. The android SDK provides tools and APIs required for Android Application Development Using Java on the Android platform. In addition to the Linux kernel, the android system architecture also provides a wide range of LIB and runtime environments for Java (the most important thing is the Dalvik virtual machine, similar to JVM), application framework and core applications. On this basis, you can quickly develop applications.

The Linux kernel is like core technical support, and Google commercialized it on mobile devices. Android development applications are similar to Windows MFC development.

How do I update the SDK after the SDK is upgraded?

A: Updating the SDK is very tricky. When a new SDK is released, it must be a plug-in. An error is that both versions exist and are not normal. Eventually, you have to uninstall them and reinstall the latest one. Then the latest SDK is working properly. We recommend that you use the same process for SDK or plugin upgrade. Simply uninstall the old version and then install the new version. Do not upgrade.

How to enter the recovery mode

A: Each Android device enters the recovery mode in different ways. Take milestone as an example: if the bootloader is 90.78, press the "X" key on the keyboard, and then press the power key to start the system. You can see the classic logo of Moto to open the two keys. Wait for a triangle icon to appear, then press the volume up key + tap the photo key, four options will appear. Open the button and select an option with the direction key. Apply update.zip to clear all data to the factory status and clear the cache.

Precautions for migrating Android bionic

A: Here is an example to illustrate what binic needs to do (the kernel header file used by bionic is upgraded from 2.6.29 to 2.6.31 ):
1) before modification, back up Android/bionic
2) copy the Linux kernel v2.6.31 header file as follows:
Copy include/ASM-generic to Bionic/libc/kernel/original folder
Copy include/Linux to Bionic/libc/kernel/original folder
Copy include/MTD to Bionic/libc/kernel/original folder
3) run the tools/update_all.py script to generate a new header file. The method is as follows.
$ CD Android/bionic/libc/kernel
$ Tools/update_all.py
The above operations will copy the new header file to the bionic/libc/kernel/common directory.
4) Delete the bionic/libc/kernel/original directory
5) copy the platform-related header files:
Copy the ASM directory related to Linux v2.6.31 to the specified path using the following method:
Copy ARCH/ARM/include/ASM to Android/bionic/libc/kernel/arch-arm/
Copy ARCH/x86/include/ASM to Android/bionic/libc/kernel/arch-x86/
6) copy the header file from v2.6.29 bionic/libc/kernel/common/Linux to the new Android/bionic/libc/kernel/common/Linux directory:
Android-alarm.h
Android-pmem.h
Android_power.h
Ashmem. h
Binder. h
Msm_adsp.h
Msm_audio.h
Msm_mdp.h
Keychord. h
7) Compile
$ CD android
$ Make-J4

What is the role of files in the vendor directory under the android source code?

A: it refers to the product models of some companies, mainly for hardware configuration, such as Radio. If Ti is used, there are some RIL interfaces provided by TI.

What is the difference between compiling Android source code and compiling Android kernel?

A: Actually, there is no difference. There are a few more Android-specific drivers. The most important thing is the binder.

How can I get pictures on my mobile phone and memory card?

Java code:

/**

* Get the absolute path of the file through URI

* @ Param URI

* @ Return

*/

Protected string getabsoluteimagepath (URI)

{

 

// Can post Image

String [] proj = {mediastore. Images. Media. Data };

Cursor cursor = managedquery (Uri, proj, // which columns to return

Null, // where clause; Which Rows to return (all rows)

Null, // where clause selection arguments (none)

Null); // order-by clause (Ascending by name)

Int column_index = cursor. getcolumnindexorthrow (mediastore. Images. Media. data );

Cursor. movetofirst ();

Return cursor. getstring (column_index );

}
Copy code
How to use dual buffering?

A: The system has implemented dual-buffering. To avoid duplication, the ondraw must be restored twice in a row or the dirty part of the previous ondraw.

It usually takes-ms to execute the bitmap. createbitmap function. to improve its efficiency, we can only pray that Google can write Android code more efficiently.

The article from: Android mobile phone network (www.anzhuopp.com) Detailed reference: http://www.anzhuopp.com/Androidshouji/3032/

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.