測試項目: (Stack 變化可從 dump app stat 中取得)
- 呼叫內部 Activity (w/wo Finish(), Stack 變化)
- 呼叫外部 Activity (w/wo Finish(), Stack 變化)
Case1: 呼叫內部 Activity by startActivity()
- Call internal activity without finish()
- A1 -> A2 -> A3, then back to HOME, then re-launch, then press return key:
- A3 -> A2 -> A1 -> HOME
- Call internal activity with finish()
- A1 -> A2.finish() -> A3, then back to HOME, then re-launch, then press return key:
- A3 -> A1 -> HOME
- 結論: 使用 finish() 後,該 activity 將會從 activity stack 中移除,等同按 Return key
Case2: 呼叫內部 Activity by stratActivityForResult()
- The program: A(A1/A2/A3)
- Case A: A1 -> (startActivity) -> A2 -> (startActivityForResult, int(pattern1)) -> A3 (get pattern1, pattern1++, Finish())
- 結論: (變數名稱要一致,且 A3 一定要搭配 Finish();)
- 假設 pattern1 = 1。A3 finish 後,A2 取出的 pattern1 = 1。(也就是說,pattern1++ 後,A2 看到的還是舊 pattern1 = 1)
- pattern1 變數名稱要一樣,若 A3 宣告成 (pat3 = pattern1, pat3++),A2 收到的 pattern1 = 0。
- Case B: A1 -> (startActivity) -> A2 -> (startActivityForResult, int(pattern1)) -> A3 (get pattern1, pattern1++, Intent-Browser)
- Browser 會直接被 Intent 起來,A2 不會收到任何 return value。
Case3: 呼叫外部 Main Activity by stratActivity()
- Two programs: A(A1/A2/A3) & B(B1/B2)
- Activity call: A(A1 -> A2 -> A3 -> B1) / B(B1 -> B2)
- Step:
- Launch A (A1 -> A2 -> A3 -> B1 -> B2) => 最後畫面是 B2
- Back to HOME, then launch B(B1 -> B2), then press return key to B(B1) => 最後畫面是 B1
- Back to HOME, then check A & B program UI
- Re-launch A => Latest UI is B2
- Re-launch B => Latest UI is B1
- Re-launch A => Still at B2
- 結論:
- 當 A3 呼叫 B1 Activity 時,Mem 會產生兩個 Process, 一個是 A 的,一個是 B 的
- 同一個 Process 所 launch 的 activity 都會在該 Task's activity stack 中,儘管包含不同 application 的 activity
Case4: 呼叫外部 Activity (呼叫 2nd's sub activity)
- Same way as case3
- 結論: (Same as Case3)
- 呼叫別人的 Layout (xx.xml),要將變數全數 implement 到 code 裡。(setContentView(R.layout.main);)
- Intent activity:
- 同一個 program:
- Intent intent1 = new Intent();
- intent1.setClass(HelloLabTest.this, Activity2.class);
- startActivity(intent1);
- 不同 program:
- Intent intent1 = new Intent();
- intent1.setClassName("com.android.test2", "com.android.test2.Activity10");
- startActivity(intent1);.
Case6: Key vs Package
- [轉] Package name 不同,則簽名key是否相同無所謂,兩個apk都可以安裝。
- [轉] Package name 相同,簽名key相同則會覆蓋
- [轉] Package name 相同,簽名不同則第二個apk安裝會失敗。
Case7: [轉] 不同 Apk,Share User ID 相同
- XML 修改: android:sharedUserId="com.demouser"
- 導出/data/system/packages.xml,查看其內容
參考資料:
- http://wallage.blog.163.com/blog/static/17389624201011010539408/
- http://www.lhzhang.org/post/2010/09/Androide9809ae8bf87e585b1e4baabe794a8e688b7IDe69da5e5ae9ee78eb0e5a49aActivitye8bf9be7a88be585b1e4baab.aspx
沒有留言:
張貼留言