0

我需要将 apk 文件从服务器下载到设备,然后在没有任何用户交互的情况下静默安装。我正在使用有根的 android 设备。有可能吗?有什么办法可以做到吗?

我使用以下代码安装 apk。但它要求用户按安装或取消。

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(sdcard,"Android/data/com.mycompany.android.games/temp/temp.apk")), "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
        context.startActivity(intent);
4

1 回答 1

0

到目前为止,我所做的是https://paulonaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/ ,它对我的​​情况很好。

有一点,我的应用程序在非 root 设备上运行,并且我通过设备制造商的平台密钥签署了我的应用程序。

于 2018-05-08T10:12:20.017 回答