Today we will learn about a new Activity Settings and Activity of the lifecycle.
Generally speaking, we understand the lifecycle first Activity, Activity of the different status. Each time a new one is introduced Activity Information in the onCreate method, so it is going to the Activity run in onStart close though. Thus, when the Activity pause iusa onPause method is to resume it again, it will come up again in the Activity running through onResume method. You can understand it more clearly seen in the diagram below.
Now we'll be setting up a new project. New Android Project If the project src> package takes on a new class file, whose name SecondActivity, who now extends SecondActivity think by Activity. Then we need to go through some of the Override method.From the menu at the top source Override / Implement Methods click like below onPause method onCreate and press the button to select ok.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| package com.art.android6; import android.app.Activity; import android.os.Bundle; public class SecondActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_second); } @Override protected void onPause() { super .onPause(); } } |
Now we'll create SecondActivity for a layout. res> layout activity_second to create a new layout. To display the Layout on SecondActivity SecondActivity.java's onCreate method will give him directions in the setContentView setContentView (Rlayout. activitysecond ); This.
Then we'll AndroidManifest this file. Here are the settings like this will just give up.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <?xml version= "1.0" encoding= "utf-8" ?> <manifest xmlns:android= "http://schemas.android.com/apk/res/android" package = "com.art.android6" android:versionCode= "1" android:versionName= "1.0" > <uses-sdk android:minSdkVersion= "8" android:targetSdkVersion= "18" /> <Application android:allowBackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/AppTheme" > <Activity android:name= "com.art.android6.MainActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "android.intent.action.MAIN" /> <category android:name= "android.intent.category.LAUNCHER" /> </intent-filter> </activity> <Activity android:name= "com.art.android6.SecondActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "com.art.android6.activity_second" /> <category android:name= "android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest> |
Here the <application inside ekatiekati <activity was part of the re-copied it for SecondActivity. And the name of the SecondActivity package name, action name has been showed in the activity_second.
Thread on the next episode, we MainActivity SecondActivity to use and learn about the application. Will ......
No comments:
Post a Comment