Android Advanced Android interview topics organized and explained (a)

Source: Internet
Author: User

This article specializes in the study of Android interview questions, content will continue to increase with the study, if the answer is wrong, I hope you can correct me

1. Brief description of activity life cycle
when activity starts, first call OnCreate (), OnStart (), Onresume () method, at which time the activity is visible to the user.
when activity changes from visible to dialog occlusion, the OnPause () method is called, and the activity is visible to the user at this time, but cannot be app user's Click event
when the activity changes from visible to being fully covered by other activity or by clicking Home into the background, the OnPause (), OnStop () method is called in turn, and if the system memory is low during this period, Causes the activity to be recycled, the Ondestory () method is also called
the Onresume () method is called when activity resumes from a state that is blocked by dialog, which restores the state that can be clicked
Onrestart (), OnStart (), Onresume () are called in turn when activity is recovered from being obscured by other activity or in the background state, and is not reclaimed by the system. Revert to a state that can interact with the user
when activity is obscured by other activity or in the background, and is reclaimed by the system, it is equivalent to reopening an activity, calling OnCreate (), OnStart (), Onresume () method, So you can interact with the user
2.Intent start activity There are several ways to do it? There are two ways to start activity intent, namely explicit intent, implicit intent the first, the explicit realization.
Intent Intent = new Intent (this,otheractivity.class);  startactivity (intent);
There is another form of explicit intent
Intent Intent = new Intent (); ComponentName component = new ComponentName (this, otheractivity.class); intent.setcomponent (component); startactivity (intent);
In fact, these two forms are actually the same, let's take a look at the code of the intent constructor
}
So we are at a glance, in fact, we often use the intent of the construction method is the second way of the simplified versionthe second is the realization of implicit intent. first, let's take a look at the implicit intent of the invocation method
Intent Intent = new Intent () intent.setaction ("other"); StartActivity (Intent);
The implicit intent is to use the setaction to distinguish between which interface to jump to, then we definitely need to jump in the page to set a flag, we need to set this in Androidmanifest.xml
<activity android:name= "com.example.lifecicledemo.OtherActivity" >            <intent-filter>                < Action android:name= "Other"/>                <category android:name= "Android.intent.category.DEFAULT"/>            </ Intent-filter>        </activity>

So when we use setaction, we can see which page we want to jump to.

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.