Android interview questions Accumulation

Source: Internet
Author: User

1. What is ANR and how to avoid it?

 

Http://blog.csdn.net/Zengyangtech/archive/2010/11/21/6025671.aspx

 

2. What will cause force close? How to avoid it? Can I capture exceptions that cause them?

3. If Android APIs do not declare that they will throw an exception, it is impossible to throw a runtime exception during runtime. Have you ever encountered this? What problems will this cause? How can this problem be solved?

 

4. Briefly explain activity, intent, intent filter, service, broadcast, broadcasereceiver

 

Http://blog.csdn.net/Zengyangtech/archive/2010/11/21/6025676.aspx

 

 

 

5. What are the advantages of intentservice?

 

Intentservice is a base class for services that handle asynchronous requests (expressed as intents) on demand. clients send requests through startservice (intent) CALS; the service is started as needed, handles each intent in turn using a worker thread, and stops itself when it runs out of work.

 

This 'work queue processor 'pattern is commonly used to offload tasks from an application's main thread. the intentservice class exists to simplify this pattern and take care of the mechanic. to use it, extend intentservice and implement onhandleintent (intent ). intentservice will receive the intents, launch a worker thread, and stop the service as appropriate.

 

All requests are handled on a single worker thread-they may take as long as necessary (and will not block the application's main loop ), but only one request will be processed at a time."

 

Benefits of intentservice

 

When processing intent, a corresponding service is generated.

The android process processor will try not to kill you

Very easy to use

Intentservice application in calendar

 

Public class dismissallalarmsservice extends intentservice {

@ Override public void onhandleintent (intent unusedintent ){

Contentresolver resolver = getcontentresolver ();

...

Resolver. Update (Uri, values, selection, null );

}

}

In alertreceiver extends broadcastreceiver, onreceive (): (main thread)

Intent intent = new intent (context, dismissallalarmsservice. Class );

Context. startservice (intent );

 

 

6. Describe Android Digital Signature Based on your understanding.

 

Android Digital Signature
In Android, all applications installed on the system must have a digital certificate used to identify the author of the application and establish a trust relationship between the application, if the protectionlevel of a permission is signature, only applications with the same digital certificate as the program where the permission is located can obtain this permission. Android uses the digital certificate-Related Mechanism of Java to add a digital certificate to APK. To understand the digital certificate of Android, you must first understand the concept of the digital certificate and the digital certificate mechanism of Java. Android requires that every application installed in the system be signed by a digital certificate, and the private key of the digital certificate is stored in the hands of the program developer. Android uses a digital certificate to identify the author of an application and establish a trust relationship between the application, instead of deciding which applications the end user can install. This digital certificate does not need to be authenticated by an authoritative Digital Certificate Signing Authority. It is only used to authenticate the application package.
Multiple programs of the same developer should use the same digital certificate as much as possible, which can bring the following benefits.
(1) It is conducive to program upgrade. When the digital certificates of the New and Old programs are the same, the android system considers the two programs as different versions of the same program. If the digital certificates of the New and Old programs are different, the android system considers them different programs and conflicts with each other, and requires the new program to change the package name.
(2) facilitates modular design and development of programs. The Android system allows a program with the same digital signature to run in a process. The Android program regards them as the same program. Therefore, developers can develop their programs into modules, and users only need to download the appropriate modules as needed.
(3) data and code can be shared among multiple programs through permission. Android provides a digital certificate-based permission granting mechanism. Applications can share functions or data with other programs to those programs that have the same digital certificate as themselves. If the protectionlevel of a permission (permission) is signature, this permission can only be granted to programs with the same digital certificate as the package where the permission is located.
When signing a certificate, you must consider the validity period of the digital certificate:
(1) The validity period of the digital certificate must include the expected life cycle of the program. Once the digital certificate expires, the program holding the certificate cannot be upgraded normally.
(2) If multiple programs use the same digital certificate, the validity period of the digital certificate should include the estimated life cycle of all programs.
(3) Android Market requires that the digital certificates of all applications be valid until January 1, October 22, 2033.
The android digital certificate contains the following key points:
(1) All applications must have digital certificates. Android does not install an application without digital certificates.
(2) the digital certificate used by the android package can be self-Signed and does not require signature authentication by an authoritative Digital Certificate Authority.
(3) To officially release an Android app, you must use a digital certificate generated by a suitable private key to sign the app, rather than using the debugging certificate generated by the ADT plug-in or ant tool for release.
(4) digital certificates are valid. Android only checks the validity period of the certificate when the application is installed. If the program has been installed in the system, the normal functions of the program will not be affected even if the certificate expires.

 

Android interview questions

1. Describe the lifecycle of an activity.
2. If the background activity is recycled by the system for some reason, How can I save the current status before being recycled by the system?
3. Set an activity as a window style. (Edited by sodino)
4. How to exit the activity? How can I safely exit the application that has called multiple activities?
5. Introduce the five la s commonly used in Android.
6. Describe how to store Android data. (Edited by sodino)
7. introduce how contentprovider achieves data sharing. (Edited by sodino)
8. How to enable and disable the service. (Edited by sodino)
9. There are several ways to register broadcast. What are the advantages and disadvantages of these methods? Let's talk about the intention of introducing the broadcast mechanism to Android.
10. Explain the relationships among message, handler, message queue, and logoff in the single-thread model.
11. What is the full name of aidl? How to work? What types of data can be processed?
12. Please explain the differences between the permissions for running Android programs and those for file systems. (Edited by sodino)
13. multiple browsers are installed on the system. Can I specify a browser to access a specified page? Describe the reason.
14. A one-dimensional integer array int [] data stores the pixel value of an image with the width and height. Write an algorithm to adjust the transparency of all the white (0 xffffffff) pixels in the image to 50%.
15. How do you evaluate the Android system? Advantages and disadvantages.

1. lifecycle of the activity.

2. lifecycle of the activity during horizontal and vertical screen Switching

Summary:

1. When the Android: configchanges of the activity is not set, the life cycle of the screen is re-called, the screen is executed once, and the screen is split twice.

2. When setting the activity's Android: configchanges = "orientation", the screen will be switched to call each lifecycle, and the screen will be executed only once

3. When the Android: configchanges = "orientation | keyboardhidden" of the activity is set, the live cycle is not re-called and only the onconfigurationchanged method is executed.

3. What are the types of animations in Android? What are their characteristics and differences?

4. Handler mechanism Principle

5. Talk about the relationship between activity, intent, and service.

6. How to communicate between threads and threads in Android and between processes

7. Complete the relative position of the widget in which lifecycle phase of the antifraud service is implemented

8. Let's talk about the principles of the MVC pattern, which is used in Android.

9. Which data storage methods are available in Android?

10. Which of the following types of XML parsing classes are available in Android? Which one is officially recommended? And their principles and differences

 

 

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.