How to push updates to preinstalled apps without allowing installation from unknown sources

人盡茶涼 提交于 2019-12-03 21:01:45
nandeesh

This method only works for system apps (source)

Try installing the apk by adding and extra field.

intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);

Have never tried this. The doc says you need to call startActivityforResult for this to work. But this requires API level 14. Also try

intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true);

Edit: On second thought, if you have custom ROM, then add shareduserid system to your installer app and directly call whatever PackageInstallerActivity is calling to install the app

Edit2:

Check this code. OnClick is used to install app, so copy the whole code to your app and add

<uses-permission android:name="android.permission.INSTALL_PACKAGES" />

permission.

And to App's Android.mk add

 LOCAL_CERTIFICATE := platform
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!