Some time ago determined to persist in writing a blog, but found that their accumulation is indeed not much, so the holiday bubble library, read some valuable articles. Harvest a lot, today's article to share the main, common learning.
Why write an explicit start and an implicit start activity. This is from an interview, Baidu engineer asked, but later feel that their answer is not good, less talk, to get to the point.
As the title, Android's acitivity startup is roughly two ways: explicit startup and implicit startup. The following are described separately:
A: Explicitly start
For starters, this is most common, and the following code explains what an explicit startup is.
Copy Code code as follows:
Intent intent=new Intent (Mainactivity.this, Secondactivity.class);
StartActivity (Intent);
B: Implicit startup
The difference in implicit startup is that we don't need to be like intent (mainactivity.this, Secondactivity.class) This passes the argument and then start another activity. We need to add filter intentfilter to the intent.
<activity
android:name= "com.example.android.tst.SecondActivity"
android:label= "@string/title_ Activity_main ">
<intent-filter>
<action android:name=" Com.example.android.tst.SecondActivity "/>
<category android:name=" Android.intent.category.DEFAULT " >
</intent-filter>
</activity>
In this way, we need to start another activity with just the following methods:
Copy Code code as follows:
Intent intent=new Intent ("com.example.android.tst.SecondActivity");
StartActivity (Intent);
Such an example would be more clear. Because not accustomed to Web page Editor Bowen, and not familiar with the attachment upload, the project will not upload, more hands most important!