├── .gitattributes ├── .gitignore ├── .gradle └── 3.3 │ ├── taskArtifacts │ ├── fileHashes.bin │ ├── fileSnapshots.bin │ ├── taskArtifacts.bin │ └── taskArtifacts.lock │ └── tasks │ └── _RecyclerViewDemo_compileDebugJavaWithJavac │ ├── localClassSetAnalysis │ ├── localClassSetAnalysis.bin │ └── localClassSetAnalysis.lock │ └── localJarClasspathSnapshot │ ├── localJarClasspathSnapshot.bin │ └── localJarClasspathSnapshot.lock ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── 01ActivityDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── activitydemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── activitydemo │ │ │ ├── AActivity.java │ │ │ ├── BActivity.java │ │ │ ├── BaseActivity.java │ │ │ └── CActivity.java │ └── res │ │ ├── layout │ │ ├── b_main.xml │ │ ├── c_main.xml │ │ ├── landscape_main.xml │ │ └── main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── activitydemo │ └── ExampleUnitTest.java ├── 01FragmentDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── fragmentdemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── fragmentdemo │ │ │ ├── activity │ │ │ ├── ActivityForCallBackActivity.java │ │ │ ├── AdapterArticleDetailActivity.java │ │ │ ├── AdapterMobileAndPadActivity.java │ │ │ ├── AddActionBarForFragmentActivity.java │ │ │ ├── AddByDynamicActivity.java │ │ │ ├── AddByStaticActivity.java │ │ │ ├── ExampleFirstActivity.java │ │ │ ├── LifeCycleActivity.java │ │ │ └── MainActivity.java │ │ │ └── fragment │ │ │ ├── ActivityForCallBackFragmentA.java │ │ │ ├── ActivityForCallBackFragmentB.java │ │ │ ├── AdapterArticleDetailFragment.java │ │ │ ├── AdapterArticleListFragment.java │ │ │ ├── AddActionBarForFragment.java │ │ │ ├── AddFragmentFirst.java │ │ │ ├── AddFragmentSecond.java │ │ │ ├── ExampleFirstFragment.java │ │ │ └── LifeCycleFragment.java │ └── res │ │ ├── layout-land │ │ └── activity_adaptermobile_and_pad.xml │ │ ├── layout │ │ ├── activity_activityforcallback.xml │ │ ├── activity_adaptermobile_and_pad.xml │ │ ├── activity_addactionbar.xml │ │ ├── activity_addbydynamic.xml │ │ ├── activity_addbystatic.xml │ │ ├── activity_articledetails_activity.xml │ │ ├── activity_examplefirst.xml │ │ ├── activity_lifecycle.xml │ │ ├── activity_main.xml │ │ ├── fragment_activityforcallback_a.xml │ │ ├── fragment_activityforcallback_b.xml │ │ ├── fragment_addactionbar.xml │ │ ├── fragment_addfragmentfirst.xml │ │ ├── fragment_addfragmentsecond.xml │ │ ├── fragment_articledetails.xml │ │ ├── fragment_examplefirst.xml │ │ ├── fragment_lifecycle.xml │ │ └── fragment_main.xml │ │ ├── menu │ │ └── main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── inchengdu.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── fragmentdemo │ └── ExampleUnitTest.java ├── 02ServiceDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── servicedemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── servicedemo │ │ │ ├── MainActivity.java │ │ │ └── service │ │ │ ├── MessengerService.java │ │ │ ├── MyIntentServiceExecuteDemo.java │ │ │ ├── MyServiceDemo.java │ │ │ └── MyServiceExecuteDemo.java │ └── res │ │ ├── layout │ │ └── main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── stat_sample.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── servicedemo │ └── ExampleUnitTest.java ├── AndroidBlogSource.iml ├── PluginDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── plugindemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── plugindemo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── plugindemo │ └── ExampleUnitTest.java ├── RecyclerViewDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── blogsource │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── blogsource │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── blogsource │ └── ExampleUnitTest.java ├── RxjavaDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── rxjavademo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── rxjavademo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── rxjavademo │ └── ExampleUnitTest.java ├── WebviewDemo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidleaf │ │ └── webviewdemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidleaf │ │ │ └── webviewdemo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidleaf │ └── webviewdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.gradle/3.3/taskArtifacts/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/taskArtifacts/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/3.3/taskArtifacts/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/taskArtifacts/fileSnapshots.bin -------------------------------------------------------------------------------- /.gradle/3.3/taskArtifacts/taskArtifacts.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/taskArtifacts/taskArtifacts.bin -------------------------------------------------------------------------------- /.gradle/3.3/taskArtifacts/taskArtifacts.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/taskArtifacts/taskArtifacts.lock -------------------------------------------------------------------------------- /.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin -------------------------------------------------------------------------------- /.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock -------------------------------------------------------------------------------- /.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin -------------------------------------------------------------------------------- /.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/.gradle/3.3/tasks/_RecyclerViewDemo_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /01ActivityDemo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /01ActivityDemo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.androidleaf.activitydemo" 9 | minSdkVersion 15 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | compile 'com.android.support:appcompat-v7:25.2.0' 31 | compile 'com.android.support.constraint:constraint-layout:1.0.1' 32 | compile 'com.android.support:design:25.2.0' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /01ActivityDemo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in G:\DevelopmentSoftWare\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /01ActivityDemo/src/androidTest/java/com/androidleaf/activitydemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.androidleaf.activitydemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.androidleaf.activitydemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /01ActivityDemo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /01ActivityDemo/src/main/java/com/androidleaf/activitydemo/AActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidleaf.activitydemo; 2 | 3 | import android.os.Bundle; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | import android.widget.Toast; 8 | 9 | public class AActivity extends BaseActivity { 10 | //声明控件对象 11 | private TextView mTextView; 12 | @Override 13 | public void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.main); 16 | Log.i(TAG, "A --> onCreate()"); 17 | //根据ID得到代表该控件的对象 18 | mTextView = (TextView)findViewById(R.id.getactivity_id_textview); 19 | 20 | /** 21 | * 得到所属栈的ID值 22 | * 当 android:launchMode="singleinstance"时,获取该Activity所在的Task 23 | */ 24 | //mTextView.setText("This AActivity belong Task's ID: "+ this.getTaskId()); 25 | 26 | /** 27 | * 当 android:launchMode="standard"时,获取该Activity的实例 28 | */ 29 | mTextView.setText("This AActivity Instance :"+ AActivity.this); 30 | } 31 | 32 | public void startAactivity(View view){ 33 | intentChange(AActivity.class); 34 | } 35 | 36 | public void startBactivity(View view){ 37 | intentChange(BActivity.class); 38 | } 39 | 40 | @Override 41 | protected void onResume() { 42 | // TODO Auto-generated method stub 43 | super.onResume(); 44 | Log.i(TAG, "A --> onResume()"); 45 | } 46 | @Override 47 | protected void onStart() { 48 | // TODO Auto-generated method stub 49 | super.onStart(); 50 | Log.i(TAG, "A --> onStart()"); 51 | } 52 | 53 | @Override 54 | protected void onRestart() { 55 | // TODO Auto-generated method stub 56 | super.onRestart(); 57 | Log.i(TAG, "A --> onRestart()"); 58 | } 59 | @Override 60 | protected void onPause() { 61 | // TODO Auto-generated method stub 62 | super.onPause(); 63 | Log.i(TAG, "A --> onPause()"); 64 | } 65 | @Override 66 | protected void onStop() { 67 | // TODO Auto-generated method stub 68 | super.onStop(); 69 | Log.i(TAG, "A --> onStop()"); 70 | } 71 | @Override 72 | protected void onDestroy() { 73 | // TODO Auto-generated method stub 74 | super.onDestroy(); 75 | Log.i(TAG, "A --> onDestroy()"); 76 | } 77 | 78 | @Override 79 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 80 | // TODO Auto-generated method stub 81 | //获取字符串 82 | String str = savedInstanceState.getString("parameters"); 83 | //显示字符串 84 | Toast.makeText(getApplicationContext(), str, Toast.LENGTH_LONG).show(); 85 | super.onRestoreInstanceState(savedInstanceState); 86 | Log.i(TAG, "A --> onRestoreInstanceState(Bundle savedInstanceState)"); 87 | } 88 | 89 | @Override 90 | protected void onSaveInstanceState(Bundle outState) { 91 | // TODO Auto-generated method stub 92 | //保存一个字符串 93 | outState.putString("parameters", "Save somethings"); 94 | super.onSaveInstanceState(outState); 95 | Log.i(TAG, "A --> onSaveInstanceState(Bundle outState)"); 96 | } 97 | } -------------------------------------------------------------------------------- /01ActivityDemo/src/main/java/com/androidleaf/activitydemo/BActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidleaf.activitydemo; 2 | 3 | import android.os.Bundle; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | /** 9 | * Android四大组件之Activity 10 | * @author AndroidLeaf 11 | */ 12 | public class BActivity extends BaseActivity { 13 | /** Called when the activity is first created. */ 14 | //声明控件对象 15 | private TextView mTextView; 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.b_main); 20 | Log.i(TAG, "B --> onCreate()"); 21 | 22 | //根据ID得到代表该控件的对象 23 | mTextView = (TextView)findViewById(R.id.getactivity_id_textview2); 24 | /** 25 | * 得到所属栈的ID值 26 | * 当 android:launchMode="singleinstance"时,获取该Activity所在的Task 27 | */ 28 | //mTextView.setText("This BActivity belong Task's ID: "+ this.getTaskId()); 29 | /** 30 | * 当 android:launchMode="standard"时,获取该Activity的实例 31 | */ 32 | mTextView.setText("This BActivity Instance :"+ BActivity.this); 33 | } 34 | 35 | public void startAactivity(View view){ 36 | intentChange(AActivity.class); 37 | } 38 | 39 | public void startCactivity(View view){ 40 | intentChange(CActivity.class); 41 | } 42 | 43 | @Override 44 | protected void onResume() { 45 | // TODO Auto-generated method stub 46 | super.onResume(); 47 | Log.i(TAG, "B --> onResume()"); 48 | } 49 | @Override 50 | protected void onStart() { 51 | // TODO Auto-generated method stub 52 | super.onStart(); 53 | Log.i(TAG, "B --> onStart()"); 54 | } 55 | 56 | @Override 57 | protected void onRestart() { 58 | // TODO Auto-generated method stub 59 | super.onRestart(); 60 | Log.i(TAG, "B --> onRestart()"); 61 | } 62 | @Override 63 | protected void onPause() { 64 | // TODO Auto-generated method stub 65 | super.onPause(); 66 | Log.i(TAG, "B --> onPause()"); 67 | } 68 | @Override 69 | protected void onStop() { 70 | // TODO Auto-generated method stub 71 | super.onStop(); 72 | Log.i(TAG, "B --> onStop()"); 73 | } 74 | @Override 75 | protected void onDestroy() { 76 | // TODO Auto-generated method stub 77 | super.onDestroy(); 78 | Log.i(TAG, "B --> onDestroy()"); 79 | } 80 | 81 | @Override 82 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 83 | // TODO Auto-generated method stub 84 | super.onRestoreInstanceState(savedInstanceState); 85 | Log.i(TAG, "B --> onRestoreInstanceState(Bundle savedInstanceState)"); 86 | } 87 | 88 | @Override 89 | protected void onSaveInstanceState(Bundle outState) { 90 | // TODO Auto-generated method stub 91 | super.onSaveInstanceState(outState); 92 | Log.i(TAG, "B --> onSaveInstanceState(Bundle outState)"); 93 | } 94 | } -------------------------------------------------------------------------------- /01ActivityDemo/src/main/java/com/androidleaf/activitydemo/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidleaf.activitydemo; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | 6 | public class BaseActivity extends Activity { 7 | 8 | //��־tag 9 | public static final String TAG = "androidLeaf"; 10 | 11 | public void intentChange(Class mClass){ 12 | Intent mIntent = new Intent(); 13 | mIntent.setClass(getApplicationContext(), mClass); 14 | this.startActivity(mIntent); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /01ActivityDemo/src/main/java/com/androidleaf/activitydemo/CActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidleaf.activitydemo; 2 | 3 | import android.os.Bundle; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | /** 9 | * @author AndroidLeaf 10 | * @category Android四大组件之Activity 11 | */ 12 | public class CActivity extends BaseActivity { 13 | 14 | //声明控件对象 15 | private TextView mTextView; 16 | 17 | @Override 18 | public void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.c_main); 21 | Log.i(TAG, "C --> onCreate()"); 22 | //根据ID得到代表该控件的对象 23 | mTextView = (TextView)findViewById(R.id.c_getactivity_id_textview); 24 | 25 | //得到所属栈的ID值 26 | mTextView.setText("This CActivity belong Task's ID: "+ this.getTaskId()); 27 | } 28 | 29 | public void startAactivity(View view){ 30 | intentChange(AActivity.class); 31 | } 32 | 33 | public void startBactivity(View view){ 34 | intentChange(BActivity.class); 35 | } 36 | @Override 37 | protected void onResume() { 38 | // TODO Auto-generated method stub 39 | super.onResume(); 40 | Log.i(TAG, "C --> onResume()"); 41 | } 42 | @Override 43 | protected void onStart() { 44 | // TODO Auto-generated method stub 45 | super.onStart(); 46 | Log.i(TAG, "C --> onStart()"); 47 | } 48 | 49 | @Override 50 | protected void onRestart() { 51 | // TODO Auto-generated method stub 52 | super.onRestart(); 53 | Log.i(TAG, "C --> onRestart()"); 54 | } 55 | @Override 56 | protected void onPause() { 57 | // TODO Auto-generated method stub 58 | super.onPause(); 59 | Log.i(TAG, "C --> onPause()"); 60 | } 61 | @Override 62 | protected void onStop() { 63 | // TODO Auto-generated method stub 64 | super.onStop(); 65 | Log.i(TAG, "C --> onStop()"); 66 | } 67 | @Override 68 | protected void onDestroy() { 69 | // TODO Auto-generated method stub 70 | super.onDestroy(); 71 | Log.i(TAG, "C --> onDestroy()"); 72 | } 73 | 74 | @Override 75 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 76 | // TODO Auto-generated method stub 77 | super.onRestoreInstanceState(savedInstanceState); 78 | Log.i(TAG, "C --> onRestoreInstanceState(Bundle savedInstanceState)"); 79 | } 80 | 81 | @Override 82 | protected void onSaveInstanceState(Bundle outState) { 83 | // TODO Auto-generated method stub 84 | super.onSaveInstanceState(outState); 85 | Log.i(TAG, "C --> onSaveInstanceState(Bundle outState)"); 86 | } 87 | } -------------------------------------------------------------------------------- /01ActivityDemo/src/main/res/layout/b_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 |