android:persistent

2016-10-28  本文已影响0人  yuansip

Case A

  1. Install test app with versionCode=1 and versionName=0.1.0 and android:persistent=true to /system/app
  2. Start it and press 'Back', then execute 'ps | grep <test app>' to get the pid
  3. Keep android:persistent=true, change versionCode to 2, versionName to 0.2.0 and replace MainActivity's AFragment tab to BFragment, so it is supposed that MainActivity should have 2 BFragment tab now.
  4. Build and install the newer test app to /data/app
  5. Execute 'ps | grep <test app>' to get the pid, you can see the pid is not changed.
  6. Start the test app by clicking the launch icon, you can see the MainActivity does not replace AFragment with BFragment, but the versionName in 'Settings->Version' has already be changed to 0.2.0. And the pid is changed.
  7. Reboot the devices, Start the test app by clicking the launch icon, you can see now the MainActivity replaces AFragment with BFragment and the versionName in 'Settings->Version' is 0.2.0

Case B

  1. Install test app with versionCode=1 and versionName=0.1.0 and android:persistent=true to /system/app
  2. Start it and press 'Back', then execute 'ps | grep <test app>' to get the pid
  3. Change android:persistent to false, versionCode to 2, versionName to 0.2.0 and replace MainActivity's AFragment tab to BFragment, so it is supposed that MainActivity should have 2 BFragment tab now.
  4. Build and install the newer test app to /data/app
  5. Execute 'ps | grep <test app>' to get the pid, you can see the pid is not changed .
  6. Start the test app by clicking the launch icon, you can see the MainActivity does not replace AFragment with BFragment, but the versionName in 'Settings->Version' has already be changed to 0.2.0. And the pid is changed.
  7. Reboot the devices, Start the test app by clicking the launch icon, you can see now the MainActivity replaces AFragment with BFragment and the versionName in 'Settings->Version' is 0.2.0

Case C

  1. Install test app with versionCode=1 and versionName=0.1.0 and android:persistent=false to /system/app
  2. Start it and press 'Back', then execute 'ps | grep <test app>' to get the pid
  3. Keep android:persistent=false, change versionCode to 2, versionName to 0.2.0 and replace MainActivity's AFragment tab to BFragment, so it is supposed that MainActivity should have 2 BFragment tab now.
  4. Build and install the newer test app to /data/app
  5. Execute 'ps | grep <test app>' to get the pid, you can see the pid is changed.
  6. Start the test app by clicking the launch icon, you can see now the MainActivity replaces AFragment with BFragment and the versionName in 'Settings->Version' is 0.2.0.

Case D

  1. Install test app with versionCode=1 and versionName=0.1.0 and android:persistent=false to /system/app
  2. Start it and press 'Back', then execute 'ps | grep <test app>' to get the pid
  3. Change android:persistent to true, versionCode to 2, versionName to 0.2.0 and replace MainActivity's AFragment tab to BFragment, so it is supposed that MainActivity should have 2 BFragment tab now.
  4. Build and install the newer test app to /data/app
  5. Execute 'ps | grep <test app>' to get the pid, you can see the pid is changed .
  6. Start the test app by clicking the launch icon, you can see now the MainActivity replaces AFragment with BFragment and the versionName in 'Settings->Version' is 0.2.0.
  7. Keep android:persistent= true, change versionCode to 3, versionName to 0.3.0 and recover MainActivity's BFragment tab back to AFragment, so it is supposed that MainActivity should both have AFragment and BFragment tab again now.
  8. Build and install the newer test app to /data/app
  9. Execute 'ps | grep <test app>' to get the pid, you can see the pid is changed .
  10. Start the test app by clicking the launch icon, you can see now the MainActivity has both AFragment and BFragment, and the versionName in 'Settings->Version' is 0.3.0.

Conclusion

Android:persistent flag of System.App has more priority then its upgraded Data.App. I suggest set android:persistent to false, otherwise it will be messed up when user tries to upgrade the pre-installed (system/app/) app from any Application Market.

上一篇下一篇

猜你喜欢

热点阅读