繁体   English   中英

以编程方式在root用户的android设备上静默安装apk文件,而无需用户询问

[英]Install apk file silently on rooted android device programatically without asking from user

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

我使用以下代码来安装apk。 但是它要求用户按Install或Cancel。

        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);

到目前为止,我所做的是https://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/ ,对于我的情况来说,它工作正常。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM