android:persistent

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容