1、  Please describe Activity Life cycle of .

activity The life cycle approaches of are :

onCreate()、onStart()、onReStart()、onResume()、onPause()、onStop()、on

Destory();

So the life cycle : from onStart() Until system call onStop()

Front desk life cycle : from onResume() Until system call onPause()

2、  How to enable Service, How to stop Service.

Service development is relatively simple , as follows :

First step : Inherit Service class

public class SMSService extends Service {}

The second step : stay AndroidManifest.xml In the document <application> In the node, the service is

Line configuration :<service android:name=".SMSService" />

Services can't run on their own , You need to call Context.startService() or

Context.bindService() Method start service . Both methods can be activated Service, however

They are used in different situations . Use startService() Method to enable the service , Callers and services

There's no connection between , Even if the caller exits , The service is still running . Use bindService() Method

Enable service , The caller is tied to the service , Once the caller exits , And the service stops ,

be plenty of “ You don't want to be born at the same time , Must die at the same time ” Characteristics .

If you plan to use Context.startService() Method start service , When the service is not created ,

The system will call the service first onCreate() Method , Then call onStart() Method . If the

startService() Method before the service has been created , Multiple calls startService() The method doesn't work

Results in multiple service creation , But it can cause multiple calls to onStart() Method . use startService() Fang

Services that can't be started , Can only call Context.stopService() Method to end the service , At the end of the service

Would call onDestroy() Method .

If you plan to use Context.bindService() Method start service , When the service is not created ,

The system will call the service first onCreate() Method , Then call onBind() Method . At this time

Users and services are bound together , The caller quit , The system will call the service first onUnbind()

Method , Then call onDestroy() Method . If the bindService() The pre method service has

Bound , Multiple calls bindService() Method does not result in multiple service and binding creation ( It's just

Is said onCreate() and onBind() Methods are not called many times ). If the caller wants to communicate with

Unbound service , You can call unbindService() Method , Calling this method also results in

The system calls the service onUnbind()-->onDestroy() Method .

The common methods of Service Lifecycle callback are as follows :

onCreate() This method is called when the service is created , This method will only be called once , No matter call

How many times startService() or bindService() Method , Services are created only once .

onDestroy() This method is called when the service is terminated .

And adoption Context.startService() Method to start the lifecycle method related to the service

onStart() Only use Context.startService() The method is called back when the service is started by the method .

This method is called when the service starts running . Multiple calls startService() Method, though not many times

Create services , but onStart() Method will be called many times .

And adoption Context.bindService() Method to start the lifecycle method related to the service

onBind() Only use Context.bindService() The method is called back when the service is started by the method .

This method is called when the caller is bound to the service , When the caller is bound to the service , Multiple calls

Context.bindService() Method does not cause the method to be called multiple times .

onUnbind() Only use Context.bindService() Method to start the service

Law . This method is called when the caller is unbound from the service

3、  Scope public,private,protected, And the difference when not writing

The difference between the following :
Scope      The current class    same package   Descendant    other package
public       √          √             √            √
protected   √          √             √             ×
friendly     √          √             ×             ×
private      √         
×             ×             ×

4、  Anonymous Inner Class ( Anonymous inner class ) Whether it can be or not? extends( Inherit ) Other classes , Whether it can be or not? implements( Realization )interface( Interface )

Anonymous inner classes are inner classes without names . You can't extends( Inherit ) Other classes , But an inner class can act as an interface , Implemented by another inner class

5、  String s = new String("xyz"); Created several String Object

Two , A character object , A character object refers to an object

6、  Please explain in the single thread model Message、Handler、MessageQueue、Looper The relationship between .

To put it simply ,Handler Get... In the current thread looper object ,looper Used to from

Deposit Message Of MessageQueue Remove from Message, There's more Handler Conduct

Message The distribution and handling of .

Message Queue( Message queue ): Used to store through Handler Published messages , Usually attached to

On one of the threads that created it , Can pass Looper.myQueue() Get the message of the current thread

queue Handler: You can publish or process a message or operate a Runnable, adopt

Handler Release the news , The message will only be sent to the message queue associated with it , However, we can only deal with

Messages in the message queue

Looper: yes Handler And message queues , Program components first pass through Handler

Deliver the message to Looper,Looper Put the message on the queue .Looper Also put... In the message queue

The message is broadcast to all

Handler:Handler After receiving the message, it is called handleMessage To deal with

Message: The type of message , stay Handler Class handleMessage In this method, we get a single

I'm going to deal with all the messages

In the single thread model , For thread communication problems ,Android Designed a Message

Queue( Message queue ), Threads can communicate with each other through this Message Queue And combine Handler and

Looper Components exchange information

7、  A brief explanation activity、 intent 、intentfilter 、service 、Broadcase、BroadcaseReceiver

One activity Presents a visual user interface that users can manipulate ; One service

Contains no visible user interface , It's running in the background , You can work with a activity binding , adopt

Binding exposes the interface and communicates with it ; One broadcast
receiver It's a wide reception

Broadcast the message and respond to it component,broadcast receiver No interface ; One

intent It's a Intent object , It holds the content of the message . about activity and service Come on

say , It specifies the name of the requested operation and the URI,Intent Objects can be explicitly

Specify a goal component. If so ,android Will find this

component( be based on manifest The statement in the document ) And activate it . But if a goal is not obvious

The formula specifies ,android The response has to be found intent The best component. It is through will

Intent Objects and goals intent filter In comparison to the people who do the work ; One

component Of intent filter tell android The component manageable

intent.intent filter Also in manifest Declared in the document .

8、  say something mvc The principle of pattern , It's in android The use of ,android The official recommendation for application development is mvc Pattern . What is meant by mvc?

mvc yes model,view,controller Abbreviation ,mvc It consists of three parts :

Model (model) object : Is the main part of the application , All business logic should be

Write on that layer .

View (view) object : Is the part of the application responsible for generating the user interface . Also in the whole

mvc The only layer that users can see in the architecture , Receive user input , Display processing results .

controller (control) object : It's based on user input , Control user interface data display and

to update model Part of the object state , A more important navigation function of the controller , Respond to the user

Related events , hand m Layer handles . android Encourage weak coupling and reuse of components , stay android in mvc The concrete embodiment of this is as follows :

1) View layer (view): It is generally used xml The file describes the interface , It's very convenient to introduce , Of course , If you are right about android If you know more , It must be

You can think of android Can also be used in javascript+html And so on view layer ,

Of course, it needs to be done here java and javascript Communication between , Fortunately, ,android Provide

The communication between them is very convenient .

2) Control layer (controller):android The responsibility of the control layer usually falls on many

acitvity On my shoulder , This sentence also implies not in acitivity Write in code , To pass the

activity Delivery model Business logic layer processing , Another reason to do this is android in

Of acitivity The response time of is 5s, If time-consuming operations are put here , The program can be easily returned

Take it away .

3) The model layer (model): Operation on Database 、 The operation of the network should be in model

Inside processing , Of course, Business Computing and other operations must also be placed in this layer .

9、  What is? ANR How to avoid it ?

ANR:Application Not Responding. stay Android in , Activity manager and windows

These two system services are responsible for monitoring the response of the application , When the user operates in 5s Inside

The program didn't respond ,BroadcastReceiver stay 10 Not finished in seconds , It will come out

Now the application has no response dialog , This is both ANR.

Avoid it :Activity It should be in its critical life cycle approach ( Such as onCreate() and

onResume()) Create as few operations as possible . Potentially time-consuming operations , For example, the network or the number of

Database operation , Or time-consuming calculations such as changing the size of the bitmap , It should be in the subthread ( Or asynchronous

The way ) To complete . The main thread should provide a Handler, In order to be able to submit

To the main thread .

10、             
What will lead to Force
Close ? How to avoid ? Whether the exception that causes it can be caught ?

Program exception , such as nullpointer.

avoid : The logic of programming is coherent , Think carefully . Can catch exceptions , stay logcat You can see the difference in the world

Constant information

11、             
short s1 = 1; s1 = s1 + 1; What's wrong with it? ? short s1 = 1; s1 += 1; What's wrong with it?

short s1 = 1; s1 = s1 + 1; (s1+1 The result is int type , Cast type required )short s1 =
1; s1 += 1;( It can compile correctly )

12、             
Overload and Override The difference between .Overloaded Whether the method of can change the type of return value

Method rewrite Overriding And overloading Overloading yes Java Different manifestations of polymorphism . rewrite Overriding It is a manifestation of polymorphism between parents and children , heavy load Overloading Is a manifestation of polymorphism in a class . If you define a method in a subclass with the same name and parameters as its parent class , We said the method was rewritten (Overriding). When subclass objects use this method , The definition in the subclass... Will be called , For it , The definition in the parent class is like being " shielding " 了 . If more than one method with the same name is defined in a class , They may have different number of parameters or different parameter types , It's called method overloading (Overloading).Overloaded You can change the type of return value

13、             
Set The elements in can't be repeated , So how to distinguish repetition from non repetition ? Yes, it is == still equals()? What's the difference between them

Set The elements in can't be repeated , Then use iterator() Method to distinguish repetition from non repetition .equals() It's about reading two Set Whether it is equal or not

equals() and == Method to determine whether the reference value points to the same object equals() Overridden in class , So that when the content and type of two separate objects match , Return true

14、             
error and exception What's the difference?

error Indicates that recovery is not a serious problem in the unlikely but difficult situation . For example, memory overflow . It's impossible to expect a program to handle such a situation

exception Represents a design or implementation problem . in other words , It means that if the program runs normally , What never happened

15、             
Please introduce ContentProvider How to realize data sharing .

A program can be implemented by Content
provider The abstract interface of will own data

Completely exposed , and Content
providers In a way similar to a table in a database

expose .Content providers Store and retrieve data , It allows all applications to access

Asked about , This is the only way to share data between applications .

To make your application's data public , It can be done by 2 Methods : Create your own

Content provider Or add your data to an existing Content provider

in , If you have the same data type and write Content
provider Authority .

How to obtain data exposed by other applications through a set of standards and unified interfaces ?

Android Provides ContentResolver, External programs can be passed through

ContentResolver Interface access ContentProvider Data provided .

16、             
try {} There's one in it return sentence , So it's right here try After finally {} Inside code Will it be carried out , When is it implemented , stay return Before or after

Will execute , stay return Pre execution

17、             
IntentService What are the advantages of ?

Acitivity The process of , When processing Intent When , There will be a corresponding Service;

Android The process processor will now try not to kill Off your ; Very easy to use

18、             
If backstage Activity It was recycled by the system for some reason , How to save the current state before being recycled by the system ?

rewrite onSaveInstanceState() Method , Save the data to be saved in this method ,

The method will be in activity Called before recovery . By rewriting onRestoreInstanceState()

Method can extract the saved data

19、             
How to put a Activity Set to window style .

:<activity> Middle configuration :android
:theme="@android:style/Theme.Dialog"

20、             
Talk about Android Of IPC( Interprocess communication ) Mechanism

IPC Short for internal process communication ,
It's sharing " name pipes " Resources for .Android Medium IPC

The mechanism is to make Activity and Service You can interact with each other at any time , Therefore, in Android

In this mechanism , Only applicable to Activity and Service Communication between , Similar to remote method calls ,

Be similar to C/S Pattern access . By defining AIDL Interface file to define IPC Interface .Servier End

Realization IPC Interface ,Client End calls IPC Interface local agent .

Android Interview questions (3) More articles about

  1. 【Android interview 】Android A collection of interview questions ( Update one after another )( newest 2012-6-18) eoe You can see it on

    ===============eoeAndroid Community recommendation :======================= 1.Android Develop Sina interview questions [ Developers must see ] Download address  http://www.eoeand ...

  2. Android Android Interview questions

    56 Two questions are often used , We can study it in depth , It is also a necessary knowledge for development . Android Android Summary of interview questions Collected some Android Interview questions , For friends who are going to interview or are interviewing . 1, Talk to you about Activit ...

  3. Android Interview question summary

    Android Interview question summary ( Constantly updated ) 1.INETNT There are several kinds related to Activit Mode of starting FLAG_ACTIVITY_BROUGHT_TO_FRONT take ACTIVITY Take it to the front FLAG_ACTIVI ...

  4. Android Arrange interview questions 【 Reprint 】

      Interview treasure (5)  http://www.apkbus.com/android-115989-1-1.html A few interview skills http://blog.sina.com.cn/s/blog_ad ...

  5. 19、android Arrange interview questions ( Charge yourself )

    ( Reprint , The source is lost , Please forgive me , If there is any suggestion , I will delete this article as soon as possible ) JAVA 1.GC What is it? ? Why would there be GC?GC It's garbage collection (Gabage Collection), Memory processing is a common problem for programmers ...

  6. Android The basis of interview questions ( turn )

    71 Taoist classics Android Interview questions and answers 1. Which of the following statements are correct about memory collection ? (b ) A. The programmer must create a thread to free memory B. The memory collector is responsible for releasing unused memory C. The memory recovery program allows the programmer to directly release ...

  7. Android Interview questions ( The content of the article comes from other people's blogs )

    Tencent interview questions 1.int a = 1; int result = a+++3<<2; 2.int a = 2; int result = (a++ > 2)?(++a):(a+=3); ...

  8. android Interview question set 1

    Android  Interview questions ( There are detailed answers ) With answers , common 100 branch One . choice question (30 topic , Each question 1.5 branch , common 45 branch ) 1.java.io Multiple stream types are defined in the package to implement input and output functions , They can be classified from different angles , According to work ...

  9. Android Interview questions collection ( There are specific answers )

    Android Interview questions and answers 1.Android dvm The process and Linux The process of , Whether the process of the application is the same concept DVM finger dalivk Virtual machine . Every Android Applications are executed in their own processes , all ...

  10. 2017 Android Interview questions [ Foundation and details ]

    2017 Android Interview questions [ Foundation and details ] thank @chuyao The questions raised , I usually write too many business codes , A lot of basic things have become ambiguous , It's not as smooth as before , By the way, Shanghai Android open ...

Random recommendation

  1. oracle Career Learning Guide

    Fengge It's a concept created by Alibaba . Its original intention is , In Alibaba IT Architecture , Get rid of IBM The minicomputers .Oracle database .EMC The storage device , Replace it with a system developed on the basis of open source software . Cisco .IBM. Google . qualcomm . Intel . Apple . ...

  2. hadoop Report errors :WARN mapred.JobClient: Error reading task outputNo route to host

    Solution : /etc/sysconfig/network/etc/hosts$hostname All three have the same host name . Specific reference :http://blog.itpub.net/28254374/vie ...

  3. How to deal with it ABBYY Error code in 142 and 55 The problem of

    In the use of ABBYY FineReader 12OCR Character recognition software to create PDF When you file , Sometimes the following error message appears : Internal program error ..\Src\SpecialFontFactory.cpp,142 And internal program errors .. ...

  4. web Project home page prompt 404

    I took it too , It is estimated that there is something wrong with the project , Can only find jsp, Can't find html and htm. hold list Cut out all the superfluous ones in , Only keep index.jsp <welcome-file-list> <welcome-fi ...

  5. Js-Html Front end series -- Display formatted text

    var dp = $("#dp").val(); var dpXSS = filterXss(dp); document.getElementById("descript ...

  6. JDK Source code - ArrayList

    /** * ArrayList Source code analysis * @author liyong * */ public class Util { @SuppressWarnings("unchecked" ...

  7. RDIFramework.NET ━ .NET Framework of rapid information system development V3.2-&gt;WinForm A new role authorization management interface is added to the version, which is more efficient 、 More normative

    The role authorization management module is mainly to set the corresponding permissions of the role . In the role authority management module , Administrators can add or remove users included in a specified role . Modules that can be assigned or granted specific roles ( menu ) Access rights of . Actions that can be recalled or assigned to a specified role ( function ) ...

  8. python Reptiles - The position ranking data of the previous period is crawling

    Abstract : Take notes to record the process of crawling the position data of the previous period , The tool used in this crawling is python, The use of IDE yes pycharm One . View page properties , Analyze data structure Open the website of the previous issue in the browser , Press F12 Or select table text - Right click - Review yuan ...

  9. Book : &lt;Hands-on ML with Sklearn &amp; TF&gt; pdf/epub

    Very good book , Recently discovered pdf edition , link :http://www.finelybook.com/hands-on-machine-learning-with-scikit-learn-and-tensor ...

  10. Android studio Import SlidingMenu problem

    Our import library In folder build.gradle It's very clear in the document : android {     compileSdkVersion 17     buildToolsVersion &q ...