Programmatically install an apk in Android 7 / api24

后端 未结 8 1851
夕颜
夕颜 2020-12-31 07:39

I am trying to get my app to automatically install an apk. This works fine for api<24. But for 24, it is failing. Android has implemented extra security:

8条回答
  •  情话喂你
    2020-12-31 08:29

    Are there any ways to allow an app to progammatically install an apk with api24?

    Add addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) to your promptInstall setup, to grant read access to the content.

    I have export=true in my manifest.

    Not on your FileProvider, as that would cause your app to crash.

    The problem seems to be that packageinstaller cannot use a content:// uri.

    No, the problem is that you did not grant permission to the package installer to read from that Uri. Had the package installer been unable to use a content scheme, you would have gotten an ActivityNotFoundException.

    Note, though, that it is only with Android 7.0 that the package installer starts supporting content. Earlier versions of Android have to use file.

提交回复
热议问题